I have a common code of serializing a class object in my 3-4 methods ,So I am thinking to create a common function for that code and call function in all the methods
I am doingn this from the following code
DataContractJsonSerializer ser = new DataContractJsonSerializer(this.GetType());
MemoryStream ms = new MemoryStream();
ser.WriteObject(ms, this);
json = Encoding.Default.GetString(ms.ToArray());
ms.Close();
I want to put this common code in seprate general function which returns Json string and which accept whole class as input parameter as I am converting whole class into a Json object , I tried creating function like
public string GenerateJsonString(class C1)
but this is giving me error on the keyword "class" saying that type is required
Can anyone tell me how can I accept whole class object in seprate method or function