

How Reverse a String in C#
See how to reverse a string. public static string ReverseString( string input) { char[] array = input.ToCharArray(); Array.Reverse(array); return new string(array); }Console.WriteLine(ReverseString(“devx”));
See how to reverse a string. public static string ReverseString( string input) { char[] array = input.ToCharArray(); Array.Reverse(array); return new string(array); }Console.WriteLine(ReverseString(“devx”));
Use the CultureInfo class to format values based on a culture. See below for an example: public static void Main() { decimal inputValue = 233; CultureInfo currentCulture = new CultureInfo(“en-US”);
See how to use this function in C# to discover how many more days are left in a given countdown. DateTime startDate = DateTime.Now;DateTime endDate = DateTime.Now.AddDays(-1);TimeSpan t = startDate
Please see below for an example of how to convert a date time to ISO 8601 format. string isoFormatDateString = dateTimeObject.ToUniversalTime().ToString(“s”) + “Z”;
See below for a short function that validates a given IP address: public static Boolean ValidateIP(string inputIP){var ipParts = inputIP.Split(‘.’);return Int32.Parse(ipParts [0]) < 256 &&Int32.Parse(ipParts [1]) < 256&Int32.Parse(ipParts [2]) <
The .NET System.Globalizaton’s NumberStyles has a parameter called AllowHexSpecifier that helps us to replace a hexString with RGB color. public static Color HexToColor(string hexString){ //replace # occurences if (hexString.IndexOf(‘#’) !=
To change the date format in C#, just use the ToUniverstalTime and the overload formatting as below: String isoFormat = inputDateTime.ToUniversalTime().ToString(“s”) + “Z”;
We can use the GetDistinaceTo?method of the GetCoordinates?class to determine the distance between two coordinates in C#. See below for an example: Using System.Device.Location;//double distance = 0.0;var aCoordinate = new
Use the System.Environment namespace’s GetFolderPath?method to retrieve the path of a special folder. It can also create the folder if it does not exist. System.Environment.GetFolderPath(Environment.SpecialFolder.Recent, Environment.SpecialFolderOption.None))