Remove method problem

aewarnick

Senior Contributor
Joined
Jan 29, 2003
Messages
1,031
int start=FileArr.LastIndexOf('.');
file=FileArr.Remove(start, FileArr.Length);

In bold is the problem. I cannot figure out a way for Remove to just go to the end of the sting, without going through alot more trouble. There should be some kind of method to do it but what is it. .Length returns the length of the whole string and an error is produced.
 
Remove's second parameter is the length of the substring to remove?

Then that would be:
file=FileArr.Remove(FileArr.LastIndexOf('.'), FileArr.Length - FileArr.LastIndexOf('.')+1);

(I suppose)
 
int start=FileArr.LastIndexOf('.');
file=FileArr.Remove(start, FileArr.Length - start);

That works perfectly.
 
Back
Top