Hi,
If I have a string, how can I get the string without the last character and then convert it to an integer?
Thank you
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
VulpesRank #55 · 29.2K reputationPosted Apr 11, 2012, 5:31 AM EDT
s = s.Substring(0,1)
or to get it as a char:
char c = s[0];
VulpesRank #55 · 29.2K reputationPosted Apr 11, 2012, 5:00 AM EDT
sabine9 reputationPosted Apr 11, 2012, 5:24 AM EDT
And if I want to read the first letter of a string?
Sam HobbsRank #107 · 20.5K reputationPosted Apr 11, 2012, 11:44 AM EDT
VulpesRank #55 · 29.2K reputationPosted Apr 11, 2012, 1:32 PM EDT
Sam HobbsRank #107 · 20.5K reputationPosted Apr 11, 2012, 4:16 PM EDT
VulpesRank #55 · 29.2K reputationPosted Apr 12, 2012, 1:39 AM EDT