P1ST0LPETE
asked on
Truncating a String in C#
What is the proper syntax to truncate (reduce) a string in C#?
For example:
myString = "SELECT * FROM table WHERE fieldname = variable AND"
and I want to cut off the last 3 characters in the string (the "AND") and make the new value be
myString = "SELECT * FROM table WHERE fieldname = variable"
For example:
myString = "SELECT * FROM table WHERE fieldname = variable AND"
and I want to cut off the last 3 characters in the string (the "AND") and make the new value be
myString = "SELECT * FROM table WHERE fieldname = variable"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
angelll is correct. However, if you have no choice in the matter,
string myString = myString.SubString(0, myString.Length - 3);
will trim the last three characters.
Jim
string myString = myString.SubString(0, myString.Length - 3);
will trim the last three characters.
Jim
ASKER
Thanks Jim.
My pleasure. Good luck.
Jim
Jim
ASKER