To get current month in string in C#/CSharp, we make use of DateTime class. Example is given below. using System; namespace Hello_World { class Program { static void Main(string args) { DateTime current = DateTime.Now; Console.WriteLine(current.ToString("MMMM")); } } } ;
To get current year in C#/CSharp, we make use of DateTime class. Example is given below. using System; namespace Hello_World { class Program { static void Main(string args) { DateTime current = DateTime.Now; Console.WriteLine(current.Year); } } } ;
To create a text file in C#/CSharp, we make use of File class which contains Create static function. This function will take text file path as parameter where you want to create the text file. using System; using System.IO; namespace Hello_World { class Program { static void Main(string args) { string file = @"C:\Users\ADMIN\Desktop\file.txt"; File.Create(file);
To split a string in C#/CSharp, we make use of Split method. This will take a character as parameter to split. In the below given example, we are passing an empty space as parameter. using System; namespace Hello_World { class Program { static void Main(string args) { string hello = "I love making tutorials."; string
For sorting an array in C#/CSharp, we make use of static method called sort which resides in Array class. Example is given below. using System; namespace Hello_World { class Program { static void Main(string args) { int array = { 9, 8, 7, 4, 3 }; Console.WriteLine("Before Sorting"); foreach (int i in array) { Console.WriteLine(i);