Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get last character in a string

I am new to developing windows phone apps. Now I am creating a text messenger app with T9 keyboard, I already made design like the buttons. Now what I want is how can I get the last character in a string? Example the string is "clyde", how can I get the char 'e' from that String? I am using Visual Basic as language.

UPDATE: Got it working now, I used this code:

string s = "clyde";
char e = s(s.Length-1);
like image 938
clydewinux Avatar asked Nov 02 '12 11:11

clydewinux


People also ask

How do I get the last 5 characters of a string?

To get the last N characters of a string, call the slice method on the string, passing in -n as a parameter, e.g. str. slice(-3) returns a new string containing the last 3 characters of the original string.


1 Answers

I'm not sure about which language are you using, but in C# it is done like

string s = "clyde";
char e = s[s.Length-1];

and it is very similar in every language.

like image 172
nothrow Avatar answered Sep 28 '22 15:09

nothrow