In PHP there is a language serialization feature. I mean: I'm not talking about using JSON
or XML
, but I'm talking about a serialization in a language-specific format.
For example, if I want to serialize a array
or a objeto
, I can easily do this.
serialize(['a' => 1, 'b' => 2])
The result will be:
'a:2:{s:1:"a";i:1;s:1:"b";i:2;}'
If I want to deserialize this data, I can invoke the unserialize
function to convert this data to a valid value in PHP.
See:
unserialize('a:2:{s:1:"a";i:1;s:1:"b";i:2;}')
The result will be:
[
"a" => 1,
"b" => 2,
]
In conclusion, this is a specific format, where the language itself will understand which data needs to be converted.
Is there something similar in C #? Is there any way to serialize native language data?
Note : Just reinforcing: I'm not talking about JSON or XML, but in a native way, as demonstrated in the PHP example.