How to retrieve values from an object? [Resolved]

Posted by Susanthampy under C# on 6/8/2011 | Points: 10 | Views : 4690 | Status : [Member] [MVP] | Replies : 6
How to retrieve values from an object in c#....


JavaScriptSerializer jss = new JavaScriptSerializer();
object obj = jss.DeserializeObject(Page.Request.Form[0].Replace("\"", "'"))


From the above code.........

The object obj contains an array of values like, obj[0]={i[d,id1])
obj[1]-{[firstaname, Susan]}
.............................

i want to simply display this values using response.write

pls help me... urgent requirement

Regards,
Susan



Responses

Posted by: Ndebata on: 6/8/2011 [Member] Starter | Points: 50

Up
0
Down

Resolved
object obj1 = "[ID,123]";

object obj2 = "[Name,xyz]";

string Key;
string Value;
String str = Convert.ToString(obj1);
if (string.IsNullOrEmpty(str) && str.Contains(","))
{
str=str.Replace("[", "").Replace("]", "");
string[] sarr=str.Split(',');
if (sarr.Length == 2)
{
Key = sarr[0];
Value = sarr[1];
}
}


Susanthampy, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ndebata on: 6/8/2011 [Member] Starter | Points: 25

Up
0
Down
Hi
If the object follows a particular pattern then try to use string functions to retrieve those values.

Thanks,
Debata

Susanthampy, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Susanthampy on: 6/8/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi Ndebata,

Thanks for your quick reply

Regards,
Susan

Susanthampy, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Susanthampy on: 6/8/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi Nbedata,

If u don't mind pls give a sample code

Regards,
Susan

Susanthampy, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Susanthampy on: 6/8/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi,

Thanks for your reply

Regards,
Susan

Susanthampy, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vijayakumarp on: 4/16/2012 [Member] Starter | Points: 25

Up
0
Down
Nice onee........

Susanthampy, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response