Passing a generic type of class ?

A

A. Burch

What is wrong with this type of generic...

I get this error....

Error 1 Inconsistent accessibility: parameter type
'System.Collections.Generic.Queue<TMQ.TheRec>' is less accessible than
method 'TMQ.Prod.Prod(System.Collections.Generic.Queue<TMQ.TheRec>)'
C:\MQueue\TMQ\Program.cs 21 16 TMQ


using System;
using System.Collections.Generic;
using System.Text;
namespace TMQ
{
class TheRec
{
public string RecSymbol;
public string RecTime;
public double RecPrice;
public TheRec(string recsymbol, string rectime, double recprice)
{
this.RecSymbol = recsymbol;
this.RecTime = rectime;
this.RecPrice = recprice;
}
}
public class Prod
{
public Prod(Queue<TheRec> q)
{
_queue = q;
}
private Queue<TheRec> _queue;

static void Main(string[] args)
{
Queue<TheRec> OPQ = new Queue<TheRec>();
}
}
}
 
B

Barry Kelly

A. Burch said:
Error 1 Inconsistent accessibility: parameter type
'System.Collections.Generic.Queue<TMQ.TheRec>' is less accessible than
method 'TMQ.Prod.Prod(System.Collections.Generic.Queue<TMQ.TheRec>)'
C:\MQueue\TMQ\Program.cs 21 16 TMQ
class TheRec

This class is internal, not public.
public class Prod
{
public Prod(Queue<TheRec> q)

And here you have a public constructor of a public class which expects a
parameter which can never be supplied by users of this class Prod which
are not inside this assembly - namely, TheRec.

The solution is either to make Prod internal (i.e. remove the 'public')
or make TheRec public (i.e. add 'public' to TheRec).

-- Barry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top