I need to store value like
string stringValue = {"E":false,"T":1,"I":[],"M":"","S":false,"ST":1};
in string.
I have a value given as above and i want to store this value in a single string. Please somebody help me.
I need to store value like
string stringValue = {"E":false,"T":1,"I":[],"M":"","S":false,"ST":1};
in string.
I have a value given as above and i want to store this value in a single string. Please somebody help me.
You can escape double quote by back slash, you can find more about escaping string here
string stringValue = "{\"E\":false,\"T\":1,\"I\":[],\"M\":\"\",\"S\":false,\"ST\":1}";
A character that follows a backslash character () in a regular-string-literal-character must be one of the following characters: ', ", \, 0, a, b, f, n, r, t, u, U, x, v. Otherwise, a compile-time error occurs, MSDN.
What you are trying to store is actually JSON
You can easily store it into a string by serializing it first:
For this you can use the JavaScriptSerializer class that is part of System.Web.Script.Serialization
using System.Web.Script.Serialization;
...
string stringValue = JavaScriptSerializer().Serialize(YourJsonObject);
//YourJsonObject here would be the object you are getting the value from.
You can then later reverse the process by deserializing it back to an object:
var myJsonObj = JavaScriptSerializer().Deserialize(stringValue);
Note: The class is part of the System.Web.Extensions
assembly.