Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Last character in a string in C#

The code below is used to find the last character of the string.

  1. using System;
  2.  
  3. namespace ConsoleApplication1
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9.  
  10. string nameFull = "code";
  11.  
  12. string LastChar = nameFull.Substring(nameFull.Length - 1, 1);
  13.  
  14. Console.WriteLine("Last character :" + LastChar);
  15. }
  16.  
  17. }
  18. }


  1. Output: e