
- 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
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
- Related Questions & Answers
- How to find the first character of a string in C#?
- Java Program to replace the first 10 characters in JTextArea
- Delete the first 10 characters from JTextArea in Java
- How to get first 100 characters of the string in Python?
- Find the player who rearranges the characters to get a palindrome string first in Python
- Displaying at most 10 characters in a string in Java
- How to extract the first n characters from a string using Java?
- How to extract first two characters from a string in R?
- Find the first repeated word in a string in C++
- Find the first repeated character in a string using C++.
- C++ program to check if first and the last characters of string are equal
- Swapping Characters of a String in C#
- Find the index of the first unique character in a given string using C++
- PHP program to find the number of characters in the string
- Find the first non-repeating character from a stream of characters in Python
Advertisements