Answers for "get last 4 digits of string c#"

C#
6

c# get last character of string

string str = "Hello World";
string substr = str.Substring(str.Length - 1);
Posted by: Guest on May-23-2020
0

Find last digit of a number in c#

        Console.WriteLine("Please write your number:");
        long n = long.Parse(Console.ReadLine());
 
        long lastDigit = n % (10);  //or int or double - whatever numeral data type suits you
        Console.WriteLine("The last digit of your number {0} is: {1}", n, lastDigit);
 
Posted by: Guest on August-28-2021
0

c# last char in string

string msg = "Hello";
string last_char = msg[^1..];
Console.WriteLine(last_char); // output:  o
Posted by: Guest on July-12-2021

Code answers related to "get last 4 digits of string c#"

C# Answers by Framework

Browse Popular Code Answers by Language