Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to cut a String in C#

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 2.23k
    Comment on it

    String.Substring :-To remove characters from begining use like this:-

    string a = "India"; 
    string sub = a.Substring(0, 3);  
    // Here 0 means from which character you have to start cutting. Index will start from 0
    // 3 means how many character you want to cut.
    // This will give **Ind**
    
    //Similary
     string sub = a.Substring(2, 3);  
    // will give **dia**
    To remove characters from end use like this:-
    string str = "India";
    str = str.Substring(0, str.Length - 2);
    // This will remove two characters from the end and will give **Ind**
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: