CSharp - String and substring

Introduction

The following code shows how to get the sub string.

Demo

using System;
class MainClass{/*from w ww .ja va  2 s  .c  o  m*/
   public static void Main(string[] args){
     string left3 = "12345".Substring (0, 3);     // left3 = "123";
     string mid3  = "12345".Substring (1, 3);     // mid3 = "234";
   }
}

If you omit the length, you get the remainder of the string:

Demo

using System;
class MainClass/*from  w  w w .  j  a v  a  2 s  . c  o m*/
{
   public static void Main(string[] args)
   {

      string end3  = "".Substring (2);

   }
}

Result