string.remove doesn't

  • Thread starter Thread starter radiolandog
  • Start date Start date
R

radiolandog

string s = "G618964";

if (s[0] == 'G')
{
s.Remove(0,1);
}

// after stepping through this code, s = "G618964"
// I was anticipating s = "618964";

Any insight you may provide is appreciated

Thanks, - dog
 
radiolandog said:
string s = "G618964";

if (s[0] == 'G')
{
s.Remove(0,1);
}

// after stepping through this code, s = "G618964"
// I was anticipating s = "618964";

Any insight you may provide is appreciated

Thanks, - dog

if (s[0] == 'G')
{
s = s.Remove(0,1);
}
 
Thanks, Ed!



Ed Courtenay said:
radiolandog said:
string s = "G618964";

if (s[0] == 'G')
{
s.Remove(0,1);
}

// after stepping through this code, s = "G618964"
// I was anticipating s = "618964";

Any insight you may provide is appreciated

Thanks, - dog

if (s[0] == 'G')
{
s = s.Remove(0,1);
}
 
I recommend you to reading
http://www.codeproject.com/dotnet/strings.asp
for an in-dept look into strings

Sk
http://dotnetscoups.blogspot.com


Thanks, Ed!




radiolandog said:
string s = "G618964";
if (s[0] == 'G')
{
s.Remove(0,1);
}
// after stepping through this code, s = "G618964"
// I was anticipating s = "618964";
Any insight you may provide is appreciated
Thanks, - dog
if (s[0] == 'G')
{
s = s.Remove(0,1);
}- Hide quoted text -

- Show quoted text -
 

Ask a Question

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.

Ask a Question

Back
Top