i have this method to serialize my objects :
    private static byte[] GetBytes(object obj) {
        byte[] result;
        using (MemoryStream ms = new MemoryStream()) {
            DataContractJsonSerializer ser = new DataContractJsonSerializer(obj.GetType());
            ser.WriteObject(ms, obj);
            result = ms.ToArray();
            ms.Close();
        }
        return result;
    }
it is normal, when i want to use this, my object parameter must a class that decorate with [System.Runtime.Serialization.DataContract] and its member must decorate with [System.Runtime.Serialization.DataMember] but how about when i want to use unknown type like :
var myVar = GetBytes(new { Name = "MyName", LastName = "LastName" });
how can i decorate unknown types with attribute
 
     
    