Click here to Skip to main content
15,884,909 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to have a method call a static <list>, that is part of a class, however, I cannot think of a way to read items within this list from a calling procedure, can you help?

C#
protected static List<ContactDetailEmail> ContactDetailEmail = new List<ContactDetailEmail>();
    protected static List<ContactDetailFax> ContactDetailFax = new List<ContactDetailFax>();
Posted
Comments
Kornfeld Eliyahu Peter 19-Nov-13 4:57am    
Not too clear. Can you show us what have you tried jet...
Er Daljeet Singh 19-Nov-13 5:18am    
read user question what you are trying to ask from our side..
bbirajdar 19-Nov-13 5:31am    
First you should know what the protected keyword means
Ziee-M 19-Nov-13 11:44am    
You have to use your class name to access static fields:
YourClassName.ContactDetailFax.Add(ContactDetailFax);

1 solution

Change the name - it is confused because it finds the class definition of that name before it looks for the static variable declaration:
C#
    ...
    contactDetailEmail.Add(new ContactDetailEmail());
    contactDetailFax.Add(new ContactDetailFax());
    }
protected static List<ContactDetailEmail> contactDetailEmail = new List<ContactDetailEmail>();
protected static List<ContactDetailFax> contactDetailFax = new List<ContactDetailFax>();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900