public static string Serialize <T>(T obj) { string @string; using (MemoryStream memoryStream = new MemoryStream()) { EntitySerializer.Serialize <T>(obj, memoryStream); @string = Encoding.UTF8.GetString(memoryStream.ToArray()); } return(@string); }