CSharp - String and substring

Introduction

The following code shows how to get the sub string.

Demo

using System;
class MainClass{// w w  w . j  av a2s. 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/*  www.j  a  v  a  2 s. c o m*/
{
   public static void Main(string[] args)
   {

      string end3  = "".Substring (2);

   }
}

Result