Problem passing List<T>

  • Thread starter Thread starter burrows.stephen
  • Start date Start date
B

burrows.stephen

HI all I have a Method that I wish to pass a generic List as a
parameter,

Code:
public void Test (List<Client> temp)
{
this.ClaimBindingSource.DataSource = temp;
}

The idea is then to bind it for a data report.

But upon trying to compile i get the following error

Error 1 Inconsistent accessibility: parameter type
'System.Collections.Generic.List<Indemnity_System.Client>' is less
accessible than method
'Indemnity_System.ReportView.Test(System.Collections.Generic.List<Indemnity_System.Client>)'

If I use an ArrayList I do not get this problem any help would be great.
 
Presumably, then, Indemnity_System.Client is scoped as internal.
ArrayList doesn't fail because the type is not exposed in the interface.
Either make Indemnity_System.Client public, or make the method internal
(since you won't be able to use it externally if the type
Indemnity_System.Client isn't public).

If you don't want to make the /class/ public, declare an interface with what
you need, and make the /interface/ public; then change the signature to
"public void Test (List<T> temp) where T : IClient" - this will allow any
list of items that support IClient

Marc
 

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

Back
Top