2
Reply

Retrieve value from array class

rahul shekar

rahul shekar

Oct 19 2016 8:31 AM
292
I have a class as below
 
public partial class Property
{
public string keyField { get; set; }

public object valueField { get; set; }
}
 
i am now creating a property like this
 
private string TrackingId { get; set; }
private string ApplicationId { get; set; } 
public Property[] Properties;
 
and assiging values like,
 
Properties = new Property[3];
Properties[0] = new Property { key = "XXX", value = TrackingId };
Properties[1] = new Property { key = "YYY", value = ApplicationId }; 
 
now i need to retrieve value from collection property dynamically, as of now i know only to retrieve static as 
 string key = request.Properties[0].key[0].ToString();
string value = (string)request.Properties[0].value;
 
 is there possibility to take dynamically by not using index value hard coded & not using for loop

Answers (2)