To trim a string in C#/CSharp, we make use of Trim() method. This will remove any extra space before and after the string. Example is given. using System; namespace Hello_World { class Program { static void Main(string args) { string hello = " Hello World "; Console.WriteLine("Before: " + hello ); Console.WriteLine("After: " + hello.Trim());
To join strings in C#/CSharp, we make use of Concat method. Example is given below. using System; namespace Hello_World { class Program { static void Main(string args) { string hello = "Hello "; string world = " World!"; string final = string.Concat(hello, world); Console.WriteLine(final); } } }
In previous tutorials, we have seen how to select HTML elements using their ID and Tag name. In this tutorial, we will proceed with another selector which is a class selector. We will select elements based on their class name. The syntax for selecting an element by class is $(‘.ClassName’). There are multiple ways of
To generate a GUID in C#/CSharp, we make use of GUID class. Example is given below. using System; namespace Hello_World { class Program { static void Main(string args) { Guid myGuid = Guid.NewGuid(); Console.WriteLine(myGuid.ToString()); } } } ;
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")); } } } ;