![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
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
How to find the first character of a string in C#?
To get the first character, use the substring() method.
Let’s say the following is our string −
string str = "Welcome to the Planet!";
Now to get the first character, set the value 1 in the substring() method.
string res = str.Substring(0, 1);
Let us see the complete code −
Example
using System; public class Demo { public static void Main() { string str = "Welcome to the Planet!"; string res = str.Substring(0, 1); Console.WriteLine(res); } }
Output
W
Advertisements