
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
How to 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
- Related Articles
- How to get last 2 characters from string in C# using Regex?
- How can I get last 4 characters of a string in Python?
- How to extract the last 4 characters from NSString?
- MySQL query to get a substring from a string except the last three characters?
- How to extract initial, last, or middle characters from a string in R?
- How to extract the last n characters from a string using Java?
- How to get last 12 digits from a string in MySQL?
- How to get odd and even position characters from a string?
- MySQL query to get substrings (only the last three characters) from strings?
- Golang Program to get characters from a string using the index
- Python program to get characters from the string using the index
- How to extract characters from a string in R?
- How to Remove Characters from a String in Arduino?
- MySQL Query to remove all characters after last comma in string?
- How to get first 100 characters of the string in Python?

Advertisements