c# .net

How to remove last three character of input string using Substring?

How to remove last three character of input string using Substring?, someone asked me to explain?

If you want to remove the last threecharacter of the string object. Here this example codedemonstrates us to remove all the character, excluding the last three using c#ASP.net framework c#.

    protected void Button1_Click(object sender, EventArgs e)

    {

    string input = "AppleBallCat";

    string sub = input.Substring(0,input.Length - 3);

    Console.WriteLine("Substring: {0}", sub);

     }

 

Output: 

Substring: AppleBall

Post your comments / questions