C#你可以从该班级中

时间:2017-09-22 11:19:19

标签: c# oop serialization

using somthing.Pakages;

namespace somthing.Entity
{
public class SomeClass
{

    // Data from new quote
    public string SomeData;

    public string SomeData;

    public string SomeData;

    public string SomeData;

    public int SomeData;

    public int SomeData;

    public int SomeData;

    public int SomeData;

    public bool SomeData;

    public string SomeData;

    public LifePolicy[] SomeData;

    public CiPolicy[] SomeData;

    public int SomeData;

    public SomeData()
    {

    }

    public void Save()
    {
        if(string.IsNullOrEmpty(ApplicantId)){
            GuidCreator guidCreator = new GuidCreator();
            ApplicantId = guidCreator.GetGuid();
        }
        string serialization = ""; // On this line i want this var as a serialisation of this class with its vales
        DataSaver dataSaver = new DataSaver("Applicant", ApplicantId, serialization);
    }

}

}

我如何将字符串serialization =设置为此类的字符串/ json,因为我需要将该数据保存为文件,但我不确定如何将此类转换为字符串以便可以使用它。

任何帮助都会非常感谢!

1 个答案:

答案 0 :(得分:1)

访问&下载: https://www.newtonsoft.com/json

然后: myString = JsonConvert.SerializeObject(this)