Results 1 to 6 of 6

Thread: [RESOLVED][2.0] Problem passing List<T>

  1. #1

    Thread Starter
    Fanatic Member Bombdrop's Avatar
    Join Date
    Apr 2001
    Location
    St Helens, England, UK
    Posts
    667

    Resolved [RESOLVED][2.0] Problem passing List<T>

    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.

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: [2.0] Problem passing List<T>

    Is Client public?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3

    Thread Starter
    Fanatic Member Bombdrop's Avatar
    Join Date
    Apr 2001
    Location
    St Helens, England, UK
    Posts
    667

    Re: [2.0] Problem passing List<T>

    Yes Client is a public class.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2.0] Problem passing List<T>

    How is the Client class or structure declared? I'm guessing that it has lower accessibility than public, right? If so then that's your problem: you're exposing a type that is not public through a method that is. The ArrayList doesn't give you the issue because ti has no specific connection to the Client type.

    And after typing that I decidied to read dee-u's post and I see that I'm a bit late with the advice.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2.0] Problem passing List<T>

    Quote Originally Posted by Bombdrop
    Yes Client is a public class.
    Or maybe I spoke too soon. Are you absolutely sure that it's public because that's the exact error message I get if I declare an internal Client class and then use the exact method declaration that you did?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6

    Thread Starter
    Fanatic Member Bombdrop's Avatar
    Join Date
    Apr 2001
    Location
    St Helens, England, UK
    Posts
    667

    Re: [2.0] Problem passing List<T>

    SOrry guys it's always the stupid things that trip you up I had not declared my class as public Sorry but thanks for the helps


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width