Guest User

Untitled

a guest
Jan 17th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. public class MyClass
  2. {
  3. public byte[] Bytes{get;set;}
  4. }
  5.  
  6. MyClass obj = new MyClass();
  7. obj.Bytes = new byte[]{1,22,44,55};
  8.  
  9. string s_result = Newtonsoft.Json.JsonConvert.SerializeObject(obj);
  10.  
  11. // my s_result looks like {"Bytes":"KQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="}
  12.  
  13. public class MyClass
  14. {
  15. [JsonIgnore]
  16. public byte[] Bytes{get;set;}
  17. public int[] MessageByte
  18. {
  19. get
  20. {
  21. if (this.Bytes == null)
  22. return null;
  23. int[] result = new int[this.Bytes.Length];
  24. for (int i = 0; i < this.Bytes.Length; i++)
  25. {
  26. result[i] = this.Bytes[i];
  27. }
  28. return result;
  29. }
  30. }
  31.  
  32. }
Add Comment
Please, Sign In to add comment