how to remove period character from a string in csharp

To remove the period character from a string in C#, you can use the Replace() method of the string class. Here's an example:

main.cs
string input = "Hello. World.";
string output = input.Replace(".", "");

Console.WriteLine(output);
100 chars
5 lines

This will replace all occurrences of the period character (.) with an empty string (""), effectively removing them from the original string. The output will be:

main.cs
Hello World
12 chars
2 lines

Note that Replace() method returns a new string with the replaced characters, as strings are immutable in C#.

related categories

gistlibby LogSnag