

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Access a character in C# StringBuilder
Firstly, set the StringBuilder −
StringBuilder str = new StringBuilder(); str.Append("premium");
To access the 5th character and display it −
Console.WriteLine(str[4]);
The following is the complete code −
Example
using System; using System.Text; public class Demo { public static void Main() { StringBuilder str = new StringBuilder(); str.Append("premium"); Console.WriteLine("String : "+str); Console.Write("Accessing 5th character : "); Console.WriteLine(str[4]); } }
Output
String : premium Accessing 5th character : i
- Related Questions & Answers
- Java Program to access character of a string
- Clear a StringBuilder in C#
- Replace a string using StringBuilder
- Iterating C# StringBuilder in a foreach loop
- Converting a StringBuilder to String in Java
- Java StringBuilder class.
- Append to StringBuilder in C#
- Default value of StringBuilder in C#
- How to use StringBuilder in C#?
- Remove substring from StringBuilder in Java
- Constructors of StringBuilder class in Java.
- Methods of StringBuilder class in Java.
- Converting String to StringBuilder in Java
- Where to use a StringBuffer/StringBuilder than a String in Java?
- Difference between StringBuffer and StringBuilder.
Advertisements