Click here to Skip to main content
15,879,348 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have two class like
C#
Class prop{
public string status {get; set;}
public string value {get; set;}
}


and

C#
Class DataFields
{
public string field1 {get;set;}
public string field2 {get;set;}
|
|

}


Now I want to set properties like

field1.status="A";
field1.Value="ABC";
field2.status="N";
field2.value="XYZ";

When I am binding the value I will just bind with field1.value or field1.status.
So can you please let me know how can I create and assign values to entities?
Posted
Updated 28-Oct-11 1:50am
v2

1 solution

You would declare field1 and field2 as class prop like this

C#
public prop field1 { get; set; }
        public prop field2 { get; set; }



and instatiate them like this :-

C#
field1.status = "A";
            field1.value = "ABC";
            field2.status = "N";
            field2.value = "XYZ";


Hope that helps
 
Share this answer
 
Comments
kumar_k508 28-Oct-11 7:55am    
But i have so many fields in a class like field1,2... and i have to create an object for that class with all properties like status, value for all the fields..
Wayne Gaylard 28-Oct-11 7:59am    
Sorry, I don't get what you are trying to say.
kumar_k508 14-Nov-11 5:44am    
Thanks Wayne, i got the solution in similar way.
Wayne Gaylard 14-Nov-11 5:47am    
No problem. Glad to help:)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900