- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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 isour 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
- Related Articles
- Find the first repeated character in a string using C++.
- Find repeated character present first in a string in C++
- Find the index of the first unique character in a given string using C++
- How to remove the first character of string in PHP?
- How to find its first non-repeating character in a given string in android?
- How to find the first 10 characters of a string in C#?
- How to print the first character of each word in a String in Java?
- How to cut only the first character in MySQL string?
- C++ Program to Find the Frequency of a Character in a String
- How to remove the first and last character in a string in R?
- Program to find the index of first Recurring Character in the given string in Python
- How do we find out if first character of a string is a number in java?
- Remove all except the first character of a string in MySQL?
- Finding the first non-repeating character of a string in JavaScript
- Java Program to Capitalize the first character of each word in a String

Advertisements