나는 이것을 구현 선택으로 ch 것이다. 심지어 -1
작품 :
는 는
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("A"));
DataColumn existent = dt.Columns[0]; // works
DataColumn nonexistent = dt.Columns[1]; // doesn't work - IndexOutOfRangeException
는
아마 누군가에 대한 통찰력을 제공 할 수 : 그것은 IndexOutOfRangeException
을 던질 수있는 표시 DataColumnCollection.Item Property (Int32) documentation와
Regex re = new Regex(@"(\d+)");
Match result = re.Match("123456789");
Console.WriteLine(result.Groups[1000000000].Value); // works: ""
Console.WriteLine(result.Groups[0].Value); // works: "123456789"
Console.WriteLine(result.Groups[-1].Value); // works: ""
명암이,
GroupCollection.Item Property (Int32) documentation는 예외를 throw하는 것은 아닙니다 그 이유 (들) GroupCollection
는 예외없이 말도 안되는 소리를 처리하고 DataColumnCollection
은 예외가있는 동일한 말도를 처리하지만, 나는 그것을 의심한다.
bool StringContains(string inString, string lookForString)
{
if (inString.IsNullOrEmpty)
return false;
// blah
}
대
bool StringContains(string inString, string lookForString)
{
if (inString == null)
throw new ArgumentNullException("inString");
if (inString.Length == 0)
throw new ArgumentException("inString cannot be empty.");
// blah
}
그리고'result.Groups [10000 : 우리 각자가 간단한 작성 선출하는 방법보다는 조금 다른이야 방법 (이미이에 대한 BCL 지원을 따로 설정을) 문자열을-포함 ]'도 null이 아닌가? 출력은 무엇입니까? – SimpleVar
예. 'string.Empty'의 값은 그 값입니다. – lexeRoy