how to add enum value to list

Posted by netmajor on Stack Overflow See other posts from Stack Overflow or by netmajor
Published on 2010-05-30T22:46:30Z Indexed on 2010/05/30 22:52 UTC
Read the original article Hit count: 388

Filed under:
|
|
|

I have enum:

    public enum SymbolWejsciowy
{
     K1 , K2 , K3 , K4 , K5 , K6 , K7 , K8 
}

and I want to create list of this enum

 public List<SymbolWejsciowy> symbol;

but in my way to add enum to List:
1.

SymbolWejsciowy symbol ;  
symbol.Add(symbol = SymbolWejsciowy.K1); 

2.
symbol.Add(SymbolWejsciowy.K1);

I always get Exception

Object reference not set to an instance of an object.

What i do wrong :/ Please help :)

© Stack Overflow or respective owner

Related posts about c#

Related posts about exception