Reputation: 102
I made a control
and I generated a string with javascript from a javascript array using
Sys.Serialization.JavaScriptSerializer.serialize(array);
this is the string generated
"["name", "Code", "Alias"]"
this string is send to my control with a postback.
Now I need to know the best way to make an array from this string using C#
Upvotes: 1
Views: 63
Reputation: 101681
You can use JavaScriptSerializer
class:
var serializer = new JavaScriptSerializer();
var array = serializer.Deserialize<string[]>(yourString);
Note: You need to add a reference to System.Web.Extensions.dll
Upvotes: 3
Reputation: 595
String[] splitByComma = yourString.Split(',');
foreach(String splitString in splitByComma)
{
splitString.Replace("\"","").Replace("[","").Replace("]","");
}
Upvotes: 0