Top community members
All Wiki Articles Create Wiki Article

Welcome to Dirask IT community! ❤ 💻
We are community that shares solutions with each other.

If you think you have something to add here.

you are welcome with your fresh ideas - List Articles

C#/.NET - remove characters from string

0 contributions
3 points

In C#/.NET it is possible to remove string characters with String.Remove method.

1. Remove last character example

string text = "abc";
//string result = text.Remove(text.Length - 1, 1);
string result = text.Substring(0, text.Length - 1);
Console.WriteLine(text);

Output:

ab

2. Remove all characters after character position example

string text = "abc";
string result = text.Remove(1);
Console.WriteLine(result);

Output:

a

3. Remove all characters between character positions example

String text = "abc";
String result = text.Remove(1, 1);
Console.WriteLine(result);

Output:

ac

4. References

  1. String.Remove - Microsoft Docs
  2. String.Substring - Microsoft Docs
0 contributions

Checkout latest Findings & News:

Checkout latest questions:

Checkout latest wiki articles:

Hey 👋
Would you like to know what we do?
  • Dirask is IT community, where we share coding knowledge and help each other to solve coding problems.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.
Read more