c# - Are there other functions that can result in "StartIndex cannot be less than zero"? -
we have customer reported receiving error message along lines of "startindex cannot less zero. parameter name: startindex". standard error message thrown in substring
, remove
functions of string
class. unfortunately, unable ahold of data failing on them, i'm forced debug looking @ source code.
i have looked incidences of substring
, remove
, verified startindex parameter not less 0. searched uses of "startindex" , verified that, in 2 cases being used first parameter of string function, not mathematically less 0 (in both cases, given return value of indexof
function, string length
, value of 2 added it, 1 smallest value have).
this suggests me either issue fixed in prior codebases, have nonstandard codebase, or i'm looking in wrong place. there other functions in c# raise sort of error text? or there way in reporting wrong input parameter? misunderstanding error message?
here's 91 methods system.dll , mscorlib.dll:
static class program { static void main() { var names = getmethodswithparameter(typeof(object), "startindex") .concat(getmethodswithparameter(typeof(uri), "startindex")) .distinct(); foreach(var name in names) { console.writeline(name); } } private static ienumerable<string> getmethodswithparameter(type assemblyorigin, string name) { foreach(var type in assemblyorigin.assembly.gettypes()) { foreach(var method in type.getmethods( bindingflags.public | bindingflags.nonpublic | bindingflags.instance | bindingflags.static)) { if(method.getparameters().any(x => x.name == name)) { yield return type.fullname + "." + method.name; } } } } }
Comments
Post a Comment