I have a class:
我上课了:
class NewsLine
{
public string text;
public string original_time;
public string link;
}
Then a method:
然后一个方法:
private void AddOnlyNew(List<NewsLine> filtered_lnl)
{
NewsLine lnl = new NewsLine();
for (int x = 0; x < filtered_lnl.Count; x++)
{
if (!AllNews.Contains(filtered_lnl[x]))
{
AllNews.Add(filtered_lnl[x]);
}
for (int y = 0; y < AllNews.Count; y++)
{
Compare(filtered_lnl[x], AllNews[y]);
}
}
}
And the Compare method:
和比较方法:
public static int Compare(NewsLine n1, NewsLine n2)
{
if (n1.text != n2.text)
return string.Compare(n1.text, n2.text);
else if (n1.original_time != n2.original_time)
return string.Compare(n1.original_time, n2.original_time);
else
return string.Compare(n1.link, n2.link);
}
Om the Compare of the Cpmare method i'm getting two errors:
我比较Cpmare方法我得到两个错误:
Error 1 Inconsistent accessibility: parameter type 'ScrollLabelTest.ListsExtractions.NewsLine' is less accessible than method 'ScrollLabelTest.ListsExtractions.Compare(ScrollLabelTest.ListsExtractions.NewsLine, ScrollLabelTest.ListsExtractions.NewsLine)'
错误1可访问性不一致:参数类型'ScrollLabelTest.ListsExtractions.NewsLine'的方法不如方法'ScrollLabelTest.ListsExtractions.Compare(ScrollLabelTest.ListsExtractions.NewsLine,ScrollLabelTest.ListsExtractions.NewsLine)'
And
和
Error 2 Inconsistent accessibility: parameter type 'ScrollLabelTest.ListsExtractions.NewsLine' is less accessible than method 'ScrollLabelTest.ListsExtractions.Compare(ScrollLabelTest.ListsExtractions.NewsLine, ScrollLabelTest.ListsExtractions.NewsLine)'
错误2可访问性不一致:参数类型'ScrollLabelTest.ListsExtractions.NewsLine'比方法'ScrollLabelTest.ListsExtractions.Compare(ScrollLabelTest.ListsExtractions.NewsLine,ScrollLabelTest.ListsExtractions.NewsLine)'更难访问
2 个解决方案
#1
0
Because your Compare
method is public and accepts parameters of NewsLine
which is internal. So either change Compare
to be internal or make NewsLine
public.
因为您的Compare方法是公共的,并接受内部的NewsLine参数。因此要么将Compare改为内部,要么将NewsLine公之于众。
#2
0
It's because your Compare method is public, but your class Newsline is private or internal; it is less accessible than Compare(). That's where "inconsistent" comes from. Make Newsline public and this should work.
这是因为您的Compare方法是公开的,但您的类新闻线是私有或内部的;它比Compare()更难访问。这就是“不一致”的来源。让Newsline公开,这应该有效。
#1
0
Because your Compare
method is public and accepts parameters of NewsLine
which is internal. So either change Compare
to be internal or make NewsLine
public.
因为您的Compare方法是公共的,并接受内部的NewsLine参数。因此要么将Compare改为内部,要么将NewsLine公之于众。
#2
0
It's because your Compare method is public, but your class Newsline is private or internal; it is less accessible than Compare(). That's where "inconsistent" comes from. Make Newsline public and this should work.
这是因为您的Compare方法是公开的,但您的类新闻线是私有或内部的;它比Compare()更难访问。这就是“不一致”的来源。让Newsline公开,这应该有效。