Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

get list of constants in class c#

public static class TypeUtilities
{
    public static List<T> GetAllPublicConstantValues<T>(this Type type)
    {
        return type
            .GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy)
            .Where(fi => fi.IsLiteral && !fi.IsInitOnly && fi.FieldType == typeof(T))
            .Select(x => (T)x.GetRawConstantValue())
            .ToList();
    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: C# [] overload 
Csharp :: c# list to observablecollection 
Csharp :: by value by reference c# 
Csharp :: c# multiple exceptions same handler 
Csharp :: c# how to check the minimum and maximum of numbers 
Csharp :: Check if list contains any of another list 
Csharp :: delete selected cells in Datagridview 
Csharp :: c# extension 
Csharp :: add one to one relationship entity framework 
Csharp :: triangle calculator 
Csharp :: symfony debug bar 
Csharp :: convert stream to base64 string c# 
Csharp :: c# sort array by value 
Csharp :: wpf dispatcher timer is inaccurate 
Csharp :: .net core web api save pdf file in local folder 
Csharp :: Moq Unittest with ILogger 
Csharp :: c# webbrowser upload file 
Csharp :: ef save changes 
Csharp :: c# ping all machines on local network 
Csharp :: unity transparent sprite 
Csharp :: mesh decimate pyvista 
Csharp :: unity editorwindowtitle obsolete 
Csharp :: delegate 
Csharp :: show double in textbox c# 
Csharp :: c# generate random date of birth but over 18 
Csharp :: C# How to implement IEnumerable<T interface 
Csharp :: checkbox on change c# xamarin forms 
Csharp :: Fix Array outside the bonus 
Csharp :: where are the viwes in .net core publish 
Csharp :: get all controlswpf 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =