String.LastIndexOf(string character, int startIndex, int count) BUG ???
-
Hi, I've spent last hour of my work trying to make String.LastIndexOf(string character, int startIndex, int count) work. I know that it's friday afternoon etc... but still, Am I overworked or is it really a bug ?? just try :
int GetLastPostion(string input, string character) { return input.LastIndexOf(character, 0, input.Length); }
crashes, eveninput.LastIndexOf(character, 0, input.Length - 1);
input.LastIndexOf(character, 0, input.Length - 2);
crashes. wtf ??? -
Hi, I've spent last hour of my work trying to make String.LastIndexOf(string character, int startIndex, int count) work. I know that it's friday afternoon etc... but still, Am I overworked or is it really a bug ?? just try :
int GetLastPostion(string input, string character) { return input.LastIndexOf(character, 0, input.Length); }
crashes, eveninput.LastIndexOf(character, 0, input.Length - 1);
input.LastIndexOf(character, 0, input.Length - 2);
crashes. wtf ??? -
ArgumentutOfRangeException: Count must be positive and count must refer to a location within the string/array/collection. Parameter name: count :mad:
Just one more question: Is it this call that is actually crashing or is it possible that this is returning a -1 (because string is not found) to a function where -1 is out of range? EDIT: From MSDN: ArgumentOutOfRangeException: count or startIndex is negative. -or- startIndex minus count specify a position that is not within this instance.
-
Hi, I've spent last hour of my work trying to make String.LastIndexOf(string character, int startIndex, int count) work. I know that it's friday afternoon etc... but still, Am I overworked or is it really a bug ?? just try :
int GetLastPostion(string input, string character) { return input.LastIndexOf(character, 0, input.Length); }
crashes, eveninput.LastIndexOf(character, 0, input.Length - 1);
input.LastIndexOf(character, 0, input.Length - 2);
crashes. wtf ???This is correct. You are asking it to start searching from the start of the string, but the method works from the end of the string. It has nothing to search for.
Upcoming events: * Glasgow: SQL Server 2005 - XML and XML Query Plans, Mock Objects, SQL Server Reporting Services... * Reading: Developer Day 5 Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website
-
Hi, I've spent last hour of my work trying to make String.LastIndexOf(string character, int startIndex, int count) work. I know that it's friday afternoon etc... but still, Am I overworked or is it really a bug ?? just try :
int GetLastPostion(string input, string character) { return input.LastIndexOf(character, 0, input.Length); }
crashes, eveninput.LastIndexOf(character, 0, input.Length - 1);
input.LastIndexOf(character, 0, input.Length - 2);
crashes. wtf ???I think you mean that reading this line, give you an exception :"CrossThread...." if this what u mean, u need to invoke the thread : if(textBox.InvokeRequired) { textBox.Invoke(method); }:-D