
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
C# program to remove n-th character from a string
To remove a character, use the remove() method and set the index from where you want to delete the character.
Firstly, set the string.
string str1 = "Amit"; Console.WriteLine("Original String: "+str1);
To delete a character at position 4.
StringBuilder strBuilder = new StringBuilder(str1); strBuilder.Remove(3, 1);
You can try to run the following code to remove nth character from a string.
Example
using System; using System.Text; public class Demo { public static void Main(string[] args) { string str1 = "Amit"; Console.WriteLine("Original String: "+str1); StringBuilder strBuilder = new StringBuilder(str1); strBuilder.Remove(3, 1); str1 = strBuilder.ToString(); Console.WriteLine("String after removing a character: "+str1); } }
Output
Original String: Amit String after removing a character: Ami
- Related Articles
- Python program for removing n-th character from a string?
- Java program for removing n-th character from a string
- C# program to replace n-th character from a given index in a string
- How to remove a particular character from a String.
- Python Program to Remove the nth Index Character from a Non-Empty String
- How to remove the last character from a string in Java?
- C# Program to change a character from a string
- C++ Program to remove spaces from a string?
- How to remove only last character from a string vector in R?
- C# Program to replace a special character from a String
- Remove the last character from a string in the Swift language
- C++ program to remove spaces from a string using String stream
- Java Program to Remove All Whitespaces from a String
- Golang program to remove all whitespaces from a string
- How to remove all text from a string before a particular character in R?

Advertisements