|
-
Aug 19th, 2005, 01:32 AM
#1
Thread Starter
PowerPoster
strings
I have been sitting here for 2 hours trying to figure out this ##!!?!?!? problem
I am VERY VERY stressed and annoyed
I was to retrieve the last character of this string "]2"
HOW do I do it? everytime I do it, I either get an exception or I get the same string returned back to me
string test = data.Substring(data.LastIndexOf("]", data.LastIndexOf("]"), 1));
?!?!?!?!?!!?
-
Aug 19th, 2005, 02:06 AM
#2
Re: strings
No need to put the length of the character since you're getting the last character
you could do substring such as this one
string test = data.substring(data.length -1).tostring()
-
Aug 19th, 2005, 03:18 AM
#3
Re: strings
If you want the last character of a string then do as mar_zim says, although you don't need the call to ToString at the end because Substring returns a String object already. If you want all the characters after the last occurrence of "]" regardless how many characters that is, us this:
Code:
string test = data.Substring(data.LastIndexOf(']') + 1);
-
Aug 19th, 2005, 04:37 AM
#4
Thread Starter
PowerPoster
Re: strings
URGH... completly forgot about it
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|