index
-
""Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index "" this is error which i got on running my proj. previously it was workin good. plz help me out. its urgent
-
""Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index "" this is error which i got on running my proj. previously it was workin good. plz help me out. its urgent
Hello! The person who can help you in this case is YOU yourself. As you have described ur problem i suggest that the best way is to debug the code and see where is the index going out of bound. I am considering that this error comes after running ur appl. regards _mubashir
-
""Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index "" this is error which i got on running my proj. previously it was workin good. plz help me out. its urgent
-
""Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index "" this is error which i got on running my proj. previously it was workin good. plz help me out. its urgent
-
who said anything about a loop? "Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox
-
who said anything about a loop? "Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox
well hes doing an index out of range. typically thats because of a for loop in code. And referring to a indexed array or collection in that way not a good practice. Iterators and enumerators should be used. Is there any other attacks you would like to make today? 1 line of code equals many bugs. So don't write any!!
-
well hes doing an index out of range. typically thats because of a for loop in code. And referring to a indexed array or collection in that way not a good practice. Iterators and enumerators should be used. Is there any other attacks you would like to make today? 1 line of code equals many bugs. So don't write any!!
ooooohhhh - aren't we TOUCHY today lol!
Ista wrote:
typically thats because of a for loop in code.
Whilst that is a cause, it's not the ONLY cause - for example, referring to session vars by index rather than name, accessing columns of a datagrid by inbdex and not name....
Ista wrote:
And referring to a indexed array or collection in that way not a good practice. Iterators and enumerators should be used.
OK - not expecting you to deign to give an explanation, but my usual question again - why? You seem to think that I have it in for you - NOT AT ALL - my questions comer from the fact that we clearly have very different coding approaches, and was hoping to learn a little from you (and would LOVE to say vice-versa, but would guess that there's NOTHING I know that you don't already ;) ) "Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox
-
ooooohhhh - aren't we TOUCHY today lol!
Ista wrote:
typically thats because of a for loop in code.
Whilst that is a cause, it's not the ONLY cause - for example, referring to session vars by index rather than name, accessing columns of a datagrid by inbdex and not name....
Ista wrote:
And referring to a indexed array or collection in that way not a good practice. Iterators and enumerators should be used.
OK - not expecting you to deign to give an explanation, but my usual question again - why? You seem to think that I have it in for you - NOT AT ALL - my questions comer from the fact that we clearly have very different coding approaches, and was hoping to learn a little from you (and would LOVE to say vice-versa, but would guess that there's NOTHING I know that you don't already ;) ) "Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox
RichardGrimmer wrote:
Whilst that is a cause, it's not the ONLY cause - for example, referring to session vars by index rather than name, accessing columns of a datagrid by inbdex and not name....
I cant think of a reason you would actually update a data grid by index. Referring to anything in a session object by index is poor programming practice in my opinion, names should be used. And really a data grid shouldn't even be accessed in that way. It sounds like I’m pickin, but there so a good reason for it. So really, if someone is accessing a collection by index they should find a better way. In my opinion.
RichardGrimmer wrote:
OK - not expecting you to deign to give an explanation, but my usual question again - why?
From my experience with design patterns, c#, ATL, and Java I have come to the conclusion that accessing indexes directly is a no-no. This mainly comes from a Java perspective because they were adamant about not using an index. So my belief is that using an Enumerator or an Iterator is all you need ( which are basically a for loop with it gets down to it). Helper search function can be used to return an Enumerator. Although I'm sure situations exist where you would be forced to use an index. I just haven't been able to come up with one. In some of my classes, I have several helper functions that perform searching functions and return an Enumerator, or an Iterator pattern if thread safety is an issue. And to be honest I haven't seen an index out of range exception in 3 years at least. But I think this is more of a design pattern awareness issue. If design patterns are used, then the need for accessing index directly is almost non existent. Although, I try not to access anything directly by a number. And last note. If you do access by a number do you really know thats a valid number after to get it? I mean in a threaded environment, you access it one second, and the next a class on another page could change it. Making your value utterly useless. Especially with Domain Neutral assemblies. And thats why I use enumerators and Iterators. Enumerators are for ignorance of threading and Iterators are in a threaded environment. Its an arguable point yes. And if you can come up with a situation where they would be beneficial I would love to debate the point. I live for debates without insults about programming.
RichardGrimme