本文介绍了错误1可访问性不一致:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行下面代码的构建时,它显示以下错误



错误1可访问性不一致:返回类型'DevotionJson.Devotion'不如方法'DevotionJson.MainPage.ReadJsonFile(string)'



分类:

public class 投入
{
public string 日期{获取; set ;}
public string 标题{获取; set ;}
public string Verse { get ; set ;}

[JsonProperty( 阅读章节)]
public string ReadChapter {获得; set ;}

[JsonProperty( 读取文本)]
public string ReadText {获得; set ;}

[JsonProperty( 一年内的圣经)]
public string BibleInOneYear { get ; set ;}

public 字符串消息{ get ; set ;}
public string Notes { get ; set ;}
}





Xaml.cs

 私人列表< devotion>奉献; 

public App()
{
InitializeComponent();
// 因为填充费用很昂贵
// 您只想在应用启动时执行一次
devotions = new List< devotion>();
AddDevotions();
}

受保护 覆盖 void OnNavigatedTo(NavigationEventArgs e)
{
int index = DateTime.Now.DayOfYear - 1 ; // 列表从0索引
textblock.Text = devotions [index] .Message; // 或其他一些属性
}

私有 void AddDevotions()
{
for int i = 1 ; i& lt; = 366 ; i ++)
{
string filePath = Assets / Dec + i.ToString()+ JS;
Devotion d = ReadJsonFile(filePath);
devotions.Add(d);
}
}

public Devotion ReadJsonFile( string JsonfilePath)
{
投入d = null ;

使用(StreamReader r = new StreamReader(JsonfilePath))
{
string json = r.ReadToEnd();
d = JsonConvert< devotion> .DeserializeObject(json);
}
return d;
}





请提供解决方案。

提前感谢您的回复

解决方案


When i ran the build of the code below it shows the following error

"Error1Inconsistent accessibility: return type 'DevotionJson.Devotion' is less accessible than method 'DevotionJson.MainPage.ReadJsonFile(string)'"

Class:

public class Devotion
{
    public string Date {get; set;}
    public string Title {get; set;}
    public string Verse {get; set;}

    [JsonProperty("Read Chapter")]
    public string ReadChapter {get; set;}

    [JsonProperty("Read Text")]
    public string ReadText {get; set;}

    [JsonProperty("Bible In One Year")]
    public string BibleInOneYear {get; set;}

    public string Message {get; set;}
    public string Notes {get; set;}
}



Xaml.cs

private List<devotion> devotions;

public App()
{
   InitializeComponent();
   // as this will be expensive to populate
   // you only want to do it once when the app starts
   devotions = new List<devotion>();
   AddDevotions();
}

protected override void OnNavigatedTo(NavigationEventArgs e)
{
   int index = DateTime.Now.DayOfYear - 1; // list is indexed from 0
   textblock.Text = devotions[index].Message; // or some other property
}

private void AddDevotions()
{
   for(int i = 1; i &lt;= 366; i++)
   {
      string filePath = "Assets/Dec" + i.ToString() + ".js";
      Devotion d = ReadJsonFile(filePath);
      devotions.Add(d);
   }
}

public Devotion ReadJsonFile(string JsonfilePath)
{
   Devotion d = null;

   using (StreamReader r = new StreamReader(JsonfilePath))
   {
      string json = r.ReadToEnd();
      d = JsonConvert<devotion>.DeserializeObject(json);
   }
   return d;
}



Kindly proffer a solution.
Thank you in advance and reply soon

解决方案


这篇关于错误1可访问性不一致:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 05:49