Given a string eg 500 chars and I want to pick a string between index 400 and index 430.
How do you write such a function?
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use the
string.Substring()method.Like
var truncString = longString.Substring(400, 30);.Note, that you should check the length of
longStringthat it is at least 430 chars. If it is not,Substringwill throw an exception.