Reputation: 61
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);
}
}
}
How would i set the string serialization = to a string/json of this class as i need to save that data as a file but im not sure how i get this class into a string so it can be used.
Any help would be amazing thanks!
Upvotes: 0
Views: 56
Reputation: 496
Visit & download: https://www.newtonsoft.com/json
Then: myString = JsonConvert.SerializeObject(this)
Upvotes: 1