不一致的可访问性 C#
Inconsistent Accessibility C#
我正在为跟踪股票开发一个自定义 UI,尽管我制作的一个 UI 导致了一个我找不到的问题。我不断收到错误消息:“可访问性不一致:参数类型 'SCM_Addin.Funds.TrackFund[]' 的可访问性低于方法 'SCM_Addin.Forms.frm_FundTracker.frm_FundTracker(SM_Addin.Funds.TrackFund[])'
我已经检查了 classes 中的保护,但我找不到任何会阻碍代码可访问性的私有变量。这是代码:
frm_FundTracker:
namespace SCM_Addin.Forms
{
public 部分 class frm_FundTracker : 表格
{
public frm_FundTracker()
{
InitializeComponent();
}
public frm_FundTracker(String[] fundsToAdd, Double[] ePrices, Double[] cPrices)
{
InitializeComponent();
int index = 0;
foreach (String fund in fundsToAdd)
{
ListViewItem newFundItem = new ListViewItem(fund);
newFundItem.SubItems.Add(ePrices[index].ToString());
newFundItem.SubItems.Add(cPrices[index].ToString());
this.list_Tracker.Items.Add(newFundItem);
index++;
}//END LOADING COLUMNS
}//END FRM_FUNDTRACKER WITH ARRAYS
public frm_FundTracker(TrackFund[] funds)
{
InitializeComponent();
foreach (TrackFund fund in funds)
{
ListViewItem newFundItem = new ListViewItem(fund.symbol);
newFundItem.SubItems.Add(fund.entryPrice.ToString());
newFundItem.SubItems.Add(fund.currentPrice.ToString());
this.list_Tracker.Items.Add(newFundItem);
}
}//END FRM_FUNDTRACKER WITH FUNDS
private void btn_Done_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Close Form?", "Close Form?", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
{
this.Dispose();
}
}
}
}
基金Class:
namespace SCM_Addin
{
class Fund
{
public String symbol { get; set; } //Symbol of the fund to be used
private int fundRow { get; set; } //Fund's spot in the Stats Sheet.
private String url1, url2, url3;
private HtmlAgilityPack.HtmlDocument doc;
private DataPuller puller;
private Dictionary<String, String> fundStats;
private SqlConnection conn;
public Fund(String sym)
{
this.symbol = sym;
this.doc = new HtmlAgilityPack.HtmlDocument();
this.puller = new DataPuller();
this.url1 = "http://finance.yahoo.com/q?s=" + this.symbol;
this.url2 = "http://finance.yahoo.com/q/ks?s=" + this.symbol;
this.url3 = "http://www.profitspi.com/stock-quote/" + this.symbol + ".aspx";
this.fundStats = new Dictionary<string, string>();
this.conn = null;
}
TrackFund class(扩展基金)
namespace SCM_Addin.Funds
{
class TrackFund : Fund
{
public double entryPrice { get; set; }
public double currentPrice { get; set; }
public TrackFund(String sym, double entryP, double curP) : base(sym)
{
this.entryPrice = entryP;
this.currentPrice = curP;
}
}
}
这是我第一次在 C# 中真正扩展 class,所以如果我扩展错了,我想可能是这样。
制作 TrackFund
class public.
public class TrackFund : Fund
{
....
}
Default accessibility for a class will be internal, 所以:
class Fund
//and
class TrackFund : Fund
...应该是
public class Fund
//and
public class TrackFund : Fund
我正在为跟踪股票开发一个自定义 UI,尽管我制作的一个 UI 导致了一个我找不到的问题。我不断收到错误消息:“可访问性不一致:参数类型 'SCM_Addin.Funds.TrackFund[]' 的可访问性低于方法 'SCM_Addin.Forms.frm_FundTracker.frm_FundTracker(SM_Addin.Funds.TrackFund[])'
我已经检查了 classes 中的保护,但我找不到任何会阻碍代码可访问性的私有变量。这是代码:
frm_FundTracker:
namespace SCM_Addin.Forms
{ public 部分 class frm_FundTracker : 表格 {
public frm_FundTracker()
{
InitializeComponent();
}
public frm_FundTracker(String[] fundsToAdd, Double[] ePrices, Double[] cPrices)
{
InitializeComponent();
int index = 0;
foreach (String fund in fundsToAdd)
{
ListViewItem newFundItem = new ListViewItem(fund);
newFundItem.SubItems.Add(ePrices[index].ToString());
newFundItem.SubItems.Add(cPrices[index].ToString());
this.list_Tracker.Items.Add(newFundItem);
index++;
}//END LOADING COLUMNS
}//END FRM_FUNDTRACKER WITH ARRAYS
public frm_FundTracker(TrackFund[] funds)
{
InitializeComponent();
foreach (TrackFund fund in funds)
{
ListViewItem newFundItem = new ListViewItem(fund.symbol);
newFundItem.SubItems.Add(fund.entryPrice.ToString());
newFundItem.SubItems.Add(fund.currentPrice.ToString());
this.list_Tracker.Items.Add(newFundItem);
}
}//END FRM_FUNDTRACKER WITH FUNDS
private void btn_Done_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Close Form?", "Close Form?", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
{
this.Dispose();
}
}
}
}
基金Class:
namespace SCM_Addin
{
class Fund
{
public String symbol { get; set; } //Symbol of the fund to be used
private int fundRow { get; set; } //Fund's spot in the Stats Sheet.
private String url1, url2, url3;
private HtmlAgilityPack.HtmlDocument doc;
private DataPuller puller;
private Dictionary<String, String> fundStats;
private SqlConnection conn;
public Fund(String sym)
{
this.symbol = sym;
this.doc = new HtmlAgilityPack.HtmlDocument();
this.puller = new DataPuller();
this.url1 = "http://finance.yahoo.com/q?s=" + this.symbol;
this.url2 = "http://finance.yahoo.com/q/ks?s=" + this.symbol;
this.url3 = "http://www.profitspi.com/stock-quote/" + this.symbol + ".aspx";
this.fundStats = new Dictionary<string, string>();
this.conn = null;
}
TrackFund class(扩展基金)
namespace SCM_Addin.Funds
{
class TrackFund : Fund
{
public double entryPrice { get; set; }
public double currentPrice { get; set; }
public TrackFund(String sym, double entryP, double curP) : base(sym)
{
this.entryPrice = entryP;
this.currentPrice = curP;
}
}
}
这是我第一次在 C# 中真正扩展 class,所以如果我扩展错了,我想可能是这样。
制作 TrackFund
class public.
public class TrackFund : Fund
{
....
}
Default accessibility for a class will be internal, 所以:
class Fund
//and
class TrackFund : Fund
...应该是
public class Fund
//and
public class TrackFund : Fund