0
votes

I'm working on a custom UI for Tracking stocks, although one UI I've made has caused an issue that I can't locate. I keep getting the error: "Inconsistent accessibility: parameter type 'SCM_Addin.Funds.TrackFund[]' is less accessible than method 'SCM_Addin.Forms.frm_FundTracker.frm_FundTracker(SM_Addin.Funds.TrackFund[])'

I've checked the protection in my classes, but I can't find any private variables that would hinder the accessibility in my code. Here is the code:

frm_FundTracker:

namespace SCM_Addin.Forms

{ public partial class frm_FundTracker : Form {

    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();
        } 

    }

}

}

Fund 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 (Extends Fund)

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;

    }

}
}

This is my first time really extending a class in C#, so if I'm extending wrong, I guess that could be it.

2

2 Answers

3
votes

Default accessibility for a class will be internal, so:

class Fund
//and
class TrackFund : Fund

...should be

public class Fund
//and
public class TrackFund : Fund
1
votes

Make the TrackFund class public.

public class TrackFund : Fund
{
 ....
}