- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C# program to remove characters starting at a particular index in StringBuilder
Set StringBuilder −
StringBuilder str = new StringBuilder("Airport");
Let’s say you need to remove characters. For that, use the Remove() method, which removes a bunch of characters beginning with a particular index −
str.Remove(3, 4);
The above removes four characters beginning from 3rd index (i.e. 4th position) −
Here is the complete code −
Example
using System; using System.Text; public class Program { public static void Main() { StringBuilder str = new StringBuilder("Airport"); Console.WriteLine("String: "+str); // removing four characters Console.Write("String after removing characters: "); str.Remove(3, 4); Console.WriteLine(str); } }
Output
String: Airport String after removing characters: Air
Advertisements