-1

Why is there a Serializable attribute [Serializable], when one can just serialize as below in Net Core?

var test= JsonSerializer.Serialize(MyObject)

What is the difference between these two?

Resources:

https://stackoverflow.com/a/5877839/12425844

https://stackoverflow.com/a/29843542/12425844

  • Calling .serialize actually serialises the object. Adding the serializable attribute allows you to be selective about which properties are serialised. – Carl Aug 27 '20 at 07:57

1 Answers1

0

Most JSON and XML formatter doesn't required [Serializable] attribute when serializing an object. But some required it, like when you using BinaryFormatter when serializing an object.

Article, Do we really need SerializableAttribute?

tontonsevilla
  • 2,649
  • 1
  • 11
  • 18