c# get last two characters of string
var result = str.Substring(str.Length - 2);
c# get last two characters of string
var result = str.Substring(str.Length - 2);
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);
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us