how to convert object in string JSON c#
var json = new JavaScriptSerializer().Serialize(obj);using System;
using System.Web.Script.Serialization;
public class MyDate
{
public int year;
public int month;
public int day;
}
public class Lad
{
public string firstName;
public string lastName;
public MyDate dateOfBirth;
}
class Program
{
static void Main()
{
var obj = new Lad
{
firstName = "Markoff",
lastName = "Chaney",
dateOfBirth = new MyDate
{
year = 1901,
month = 4,
day = 30
}
};
var json = new JavaScriptSerializer().Serialize(obj);
Console.WriteLine(json);
}
}
Also in C#:
- unity change text
- regex replace all special characters
- c# get desktop path
- how to create a list c#
- how to find the area of a circle
- how to convert object in string JSON c#
- c# trim string
- get random value from list c#
- unity rigidbody addforce
- c# join string array
- .net core copy file in folder to root
- math class C# exponents
- c# program exit
- c# discord bot
- Linq - Random Elements
- kotlin random number
- .net core cli
- sticky footer bootstrap 3
- how to find the type of a object c#
- how to redirect to extern page in .net core
- c# return two variables of different types
- how to set progress openedge driver name for odbc connection c#
- ignore fakeiteasy
- c# console delay