 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP 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
How to find the first 10 characters of a string in C#?
To get the first 10 characters, use the substring() method.
Let’s say the following is our string −
string str = "Cricket is a religion in India!";
Now to get the first 10 characters, set the value 10 in the substring() method as shown below −
string res = str.Substring(0, 10);
Let us see the complete code.
Example
using System; public class Demo {    public static void Main() {       string str = "Cricket is a religion in India!";       string res = str.Substring(0, 10);       Console.WriteLine(res);    } }  Output
Cricket is
Advertisements
 