CSharp - String and substring

Introduction

The following code shows how to get the sub string.

Demo

using System;
class MainClass{/*from  w w  w  . j  ava2 s  . com*/
   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  va  2s  .  co  m*/
{
   public static void Main(string[] args)
   {

      string end3  = "".Substring (2);

   }
}

Result