How do I serialize an enum value as an int?

后端 未结 6 691
长发绾君心
长发绾君心 2020-11-28 05:48

I want to serialize my enum-value as an int, but i only get the name.

Here is my (sample) class and enum:

public class Request {
    public RequestTy         


        
6条回答
  •  眼角桃花
    2020-11-28 06:50

    Take a look at the System.Enum class. The Parse method converts a string or int representation into the Enum object and the ToString method converts the Enum object to a string which can be serialized.

提交回复
热议问题