ozzy_mra ozzy_mra - 18 days ago 7
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

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> { .... };