
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Get Last 4 Characters from String in C#
Firstly, set the string −
string str = "Football and Tennis";
Now, use the substring() method to get the last 4 characters −
str.Substring(str.Length - 4);
Let us see the complete code −
Example
using System; public class Demo { public static void Main() { string str = "Football and Tennis"; string res = str.Substring(str.Length - 4); Console.WriteLine(res); } }
Output
nnis
Advertisements