//Printing to console Console.WriteLine("Hello, World!"); //Receiving input from user Console.Write("Enter your name: "); string name = Console.ReadLine(); Console.WriteLine("Hello, " + name + "!");
//Serializing an object to JSON MyObject obj = new MyObject(); string json = JsonConvert.SerializeObject(obj); //Deserializing JSON to an object string jsonString = "{\"FirstName\":\"John\",\"LastName\":\"Doe\",\"Age\":30}"; MyObject obj = JsonConvert.DeserializeObject(jsonString);
//Reading a text file string filePath = "C:\\MyFile.txt"; string content = File.ReadAllText(filePath); //Writing to a text file string filePath = "C:\\MyFile.txt"; string content = "This is some content."; File.WriteAllText(filePath, content); //Creating a directory string directoryPath = "C:\\MyFolder"; Directory.CreateDirectory(directoryPath);