Tag: string
How to convert an Integer to Octal string in C# ?
You can easily format an integer to an octal string in C# using the Convert.ToString method. Below is a sample sourcecode that demonstrates How to convert an Integer to Octal string in C# ?
How to Populate XDocument from String in C# ?
To populate the XDocument from a string in C# , we can use the Parse method defined in the XDocument class. Below is a sample code snippet that demonstrates how to populate XDocument from string in C#. How to Populate XDocument from String in C# ?
How to display the string value of a Enum in C# ?
Below is a sample sourcecode that demonstrates how to display the string value of a Enum in C# ?
How to Extract number from a string using C# ?
Regular expression lets you to do some of the tasks quickly in C# and now such of the task that can be done using the Regex class is to extract number from a string using C# .
How to reverse a string in C#?
Below is a sample code snippet demonstrating on how to reverse a string in C#? How to reverse a string in C#?
How to remove non alphanumeric characters (special characters) from a string in C# ?
One of the simplest way to remove non alphanumeric characters from a string is using the regular expressions . Below is a sample code snippet that demonstrates how to delete the non alphanumeric characters from a string in C#. How to remove non alphanumeric characters (special characters) from a string in C# ?
Concatenate or Join a string Array using LINQ in C#
Want to join the items inside the string array say with, delimiter using LINQ in C#? It’s pretty easy. Below is a sample code snippet demonstrating in easy steps on how to concatenate a string array using LINQ in C#? Concatenate or Join a string Array using LINQ in C#
How to convert an Integer to Hexadecimal string in C# ?
You can easily format an integer to an Hexadecimal string in C# using the ToString() method. How to convert an Integer to Hexadecimal string in C# ? Below is a sample sourcecode that demonstrates How to convert an Integer to Hexadecimal string in C# ?
Case insensitive string comparison for Contains in C#
When using the string.contains method , the comparison is done based on the exact string that is passed as parameter. In this case , the comparison is case-sensitive. using System; namespace ACConsoleApp { class Program { static void Main(string[] args) { string input = “This is a WeLcome string”; var output = input.Contains(“Welcome”); Console.WriteLine(output); Console.ReadLine(); } } } In the above code snippet , the…
Count the Occurrences of String within another String in C#
Do you want to find the number of occurrences of a string within a string in C#? This article will explain how to do it. How would you count occurrences of a string within a string (C#)? For example, assume that the main string is “Abundantcode is a programming, soucrecode, technology related website”. If we need to find the number of occurrences of the comma…
How to embed Quotes in a String in C# ?
You can embed Quotes within a string in C# by using the escape sequence character . Just prefix the quotes with a back slash (\). How to embed Quotes in a String in C# ? Below is a sample sourcecode demonstrating How to embed Quotes in a String in C# ?
How to embed quotes inside string in C# ?
If you want to embed quotes within a string in C# , you can use the escape sequence \ followed by the double quotes. How to embed quotes inside string in C# ? Below is a sample sourcecode demonstrating How to embed quotes inside string in C# .
How to Get the Maximum value from a List of String using LINQ in C# ?
In one of the previous article , we explained how to get the maximum value from a list of integer using LINQ query in C# . What happens when the column is a string instead of integer ?. Below are 2 possibilities on how to get the maximum value from a list of string. How to Get the Maximum value from a List of String…
How to repeat a string N number of times in C# ?
Do you want to repeat a string N number of times in C# ? . You can use the string.concat and Enumerable.Repeat to achieve it in .NET Framework 4.0 and higher. How to repeat a string N number of times in C# ?
Writing the String to the Output Window in Visual Studio 2013
Below is a sample code snippet that demonstrates how to write a string to the Output Windows in Visual Studio 2013. Writing the String to the Output Window in Visual Studio 2013
How to get last four characters from a string in C#?
This post will provide a simple tip showing how you can get the last 4 characters from a string in C#. How to get last four characters from a string in C#? Assume that you have a string that contains the value “CodersEditor.com” and you wish to get .com from the string and display it. Below is a sample code snippet demonstrating how you can…
How to convert a string to integer in C# ?
You can convert a string to integer in C# using the following functions 1. Int32.Parse / int.Parse 2. Convert.ToInt32 3. Int.TryParse() How to convert a string to integer in C# ? Below is a sample sourcecode demonstrating the usage of the above functions The advantage of using the int.tryparse is that when the string (str) in the above example is a invalid number , a…