c# convert enum to list
Enum.GetValues(typeof(SomeEnum)).Cast<SomeEnum>();
c# convert enum to list
Enum.GetValues(typeof(SomeEnum)).Cast<SomeEnum>();
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;
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us