S
SamIAm
How do I extract the last 3 characters of a string i.e.
string s = "000001" I want "001"
Thanks,
S
string s = "000001" I want "001"
Thanks,
S
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
SamIAm said:How do I extract the last 3 characters of a string i.e.
string s = "000001" I want "001"
!How do I extract the last 3 characters of a string i.e.
string s = "000001" I want "001"
Jeff Green said:string temp = "";
string s = "000001";
for (int i = s.Length - 3; i < s.Length ; i++)
{
temp += s; // the three characters you're looking for
// are now in the string 'temp';
}
How do I extract the last 3 characters of a string i.e.
string s = "000001" I want "001"
Hope that helps...Jeff
- --
Jeff Green
Greentrees - All pigs fed and ready to fly
(e-mail address removed)
Jeff Green said:string temp = "";
string s = "000001";
for (int i = s.Length - 3; i < s.Length ; i++)
{
temp += s; // the three characters you're looking for
// are now in the string 'temp';
}
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.