Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# convert enum to list

Enum.GetValues(typeof(SomeEnum)).Cast<SomeEnum>();
Comment

convert list string to list enum c#

public static class StringEnumerableExtensions {
    public static IEnumerable<T> StringsToEnums<T>( this IEnumerable<string> strs) where T : struct, IConvertible {
        Type t = typeof( T );

        var ret = new List<T>();

        if( t.IsEnum ) {
            T outStr;
            foreach( var str in strs ) {
                if( Enum.TryParse( str, out outStr ) ) {
                    ret.Add( outStr );
                }
            }
        }

        return ret;
    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: blazor image button 
Csharp :: bind repeater to dictionary 
Csharp :: wpf keydown detect if control key is down 
Csharp :: c# asp.net hover tooltip 
Csharp :: get current location latitude and longitude in xamarin - NAYCode.com 
Csharp :: unity hide mouse first person 
Csharp :: c# mock ref parameter 
Csharp :: unity for loop array 
Csharp :: browser folder in wpf 
Csharp :: how to use open hardware monitor in c# 
Csharp :: c# system cryptography hash string 
Csharp :: c# temporary files 
Csharp :: android jaca how to pass a imageurl in a recyclerview adapter 
Csharp :: c# get all occurrences of a string 
Csharp :: .net core login redirect loop 
Csharp :: gql query with parameters 
Csharp :: c# anonymous type as return value 
Csharp :: ssis sql query in script task 
Csharp :: How to execute script in C# 
Csharp :: reflection get enum value C# 
Csharp :: delete selected cells in Datagridview 
Csharp :: datatable in c# 
Csharp :: string.format() c# 
Csharp :: overridable method C# 
Csharp :: .net core web api save pdf file in local folder 
Csharp :: how to make a C# game launcher 
Csharp :: internal working of ioc container c# 
Csharp :: decode token to get claims value 
Csharp :: ef6 export update 
Csharp :: c# sequential struct char array fixed size 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =