Answer the question
In order to leave comments, you need to log in
Is it possible to serialize structures in C#?
Good afternoon.
In connection with one problem, it was necessary to serialize the Dictionary, where MyStruct is my structure. The task is small, the number of objects is not more than a hundred, so you don’t have to worry about speed. Usually in such cases I use json.net (newtonsoft) and everything works with a bang.
This time, the problem arose because of the structures: in json.net, to deserialize them, you need to write a custom handler. Question: what can be used in .net to serialize structures (ideally, without unnecessary gestures)?
Upd. I solved the problem head-on: by writing\reading from .xml. The structure is simple, such a solution looks faster than studying third-party libs. But the question remains for the future.
upd2 here _suggest using unsafe serialization (read, custom read / write methods, or marshaling and attributes for alignment), and protobuf.net (there are two drawbacks: either the old one, and you need to hang attributes on the structure fields).
Upd3 xml formatter won't work, there are private fields.
Answer the question
In order to leave comments, you need to log in
Part of the question was eaten by the parser, try to paste the code using the appropriate markup block.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question