ozzy_mra ozzy_mra - 4 months ago 22
C# Question

Make a constant list of some data in application

In my application, i want to have a list like this

Group Kind TableName Condition
----- ---- --------- ----------
sh Send TableA Null
sh New TableB kbsn=0
jn Receive TableC Null

This list must use in whole of my application and it's values always is constant.
Now,how do i define this list in a class in my C# application and how can i read or query from this list?

Answer Source

Create a Class and add fields to it.

Here is a code:

Class MyCustomClass
    public string Group { get; set; }   
    public string Kind { get; set; }  
    public string TableName { get; set; }  
    public string Condition { get; set; }  

Define static list of MyCustomClass and initialize in application at proper place and use it everywhere in application.

static List<MyCustomClass> lstMyCustomClass  = new List<MyCustomClass> { .... };