Is there a function that will remove the last 4 char of a string? trimend works but i have to specify which chars. what if i dont know what the chars will be. I still need to remove the last 4 chars. any ideas?

Hello...consider the following:

string testString = "Sometime";
int startPos = testString.Length - 4;
//call the string.Remove(int startPosition) method that deletes characters 
//starting from that specified position.
//new string should show "Some"
testString = testString.Remove(startPos);

Hope this helps...

string test="GoodLuck";
test=test.Substring(0,test.Length-4);

This will remove the last four characters from the string

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.