friendsterTalk - Friendster Forum

friendsterTalk - Friendster Forum

Welcome guest! Please Login or Register.

#1  2008-11-11 17:18:05

creamownedz
 active server protocol
creamownedz's display avatar
» FriendsterTalker
PsychoCoder
Class-S
Location: Ftalk & MCTF
Registered: 2008-03-22
Posts: 115
Last visit: Yesterday
Reputation: 7

Retrieve value from Enum [c#]

This is a sniet I use to retrieve the values form an enum, and populating a Collection with the returned values



Instructions:
Pass the snippet the enum you want the value from and watch it work.

Make sure you have using System.Collections.ObjectModel; in your class


Code:

public Collection<String> LoadCsvTypes(Type _enum)
{
    Collection<String> str = new Collection<string>();
    //get the names from the enumeration
    string[] names = System.Enum.GetNames(_enum);
    //Now we loop through all the names in the enum list
    for (int i = 0; i <= names.Length - 1; i++)
    {
        str.Add(names[i]);
    }
    return str;
}

...Giving of reputation are highly appreciating for me...
Computers don't make errors what they do they do on purpose
...computer is my expertise...
....an addicted coder....
....don't ripp all my tutorials....

Search Friendstertalk

Board footer

FriendsterTalk is not affiliated with Friendster.com
Copyright © 2002–2009 PunBB

[ 8 queries - 0.028 second ]

Pay Per Click Ads by pay per click advertising by Kontera

FriendsterTalk.com x

Welcome to FriendsterTalk! You'll need to login in order to fully use all the features and view all the sections of this site.

Please register if you're not yet a member. =)