지연된 실행 코드를 단순화했습니다. 그러나 try/catch에서 랩핑하지 않고 다음 코드가 null/empty가 아닌지 확인하는 방법은 무엇입니까? 열거에서 현재 항목 당신은 그렇게 할 수 없습니다'지연로드'NULL 테스트 C#에서 IEnumerable?
string[] nullCollection = null;
IEnumerable<string> ienumerable = new[] { nullCollection }.SelectMany(a => a);
bool isnull = ienumerable.GetEnumerator().Current == null;
if (!isnull)
{
bool isany = ienumerable.Any();
}
@MrinalKamboj SelectManyIterator가 null 요소와 함께 호출되기 때문에 Throw되는 NullReferenceException입니다. –
@RB. 그 까다로운, 내 위의 포인트 중 아무도 보유하지 않습니다 –