943,856 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 3175
  • C# RSS
Jul 28th, 2008
0

string manipulation

Expand Post »
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?
Similar Threads
Reputation Points: 7
Solved Threads: 0
Junior Poster
mrjoli021 is offline Offline
170 posts
since Mar 2007
Jul 28th, 2008
0

Re: string manipulation

Hello...consider the following:

C# Syntax (Toggle Plain Text)
  1. string testString = "Sometime";
  2. int startPos = testString.Length - 4;
  3. //call the string.Remove(int startPosition) method that deletes characters
  4. //starting from that specified position.
  5. //new string should show "Some"
  6. testString = testString.Remove(startPos);

Hope this helps...
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rsoliz is offline Offline
6 posts
since Jul 2008
Sep 3rd, 2008
0

Re: string manipulation

C# Syntax (Toggle Plain Text)
  1. string test="GoodLuck";
  2. test=test.Substring(0,test.Length-4);

This will remove the last four characters from the string
Reputation Points: 8
Solved Threads: 0
Junior Poster in Training
FaridMasood is offline Offline
59 posts
since Mar 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: 3D Graphic in C#?
Next Thread in C# Forum Timeline: cannot parse custom config section





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC