C# Array.Find提供NullReferenceException

C# Array.Find提供NullReferenceException,c#,asp.net,C#,Asp.net,由于数组中有空元素,我的页面正在崩溃。Find命令: if (m_dynamicCheckBoxLists != null) { CheckBoxList myCbl1 = Array.Find(m_dynamicCheckBoxLists, element => element.ID == strFieldId); 使用断点,我可以看到元素为null 如何在不发生碰撞的情况下绕过此问题?尝试更换: element =&g

由于数组中有空元素,我的页面正在崩溃。Find命令:

     if (m_dynamicCheckBoxLists != null)
            {
                CheckBoxList myCbl1 = Array.Find(m_dynamicCheckBoxLists, element => element.ID == strFieldId);
使用断点,我可以看到元素为null

如何在不发生碰撞的情况下绕过此问题?

尝试更换:

element => element.ID == strFieldId
与:

由于
&&
短路,在
元素==null
的情况下,它不会对
element.ID==strfiedid
进行评估,请尝试更换:

element => element.ID == strFieldId
与:


由于
&
短路,在
元素==null

Array.Find(m_dynamiccheckbox列表,元素=>element!=null&&element.ID==strFieldId)的情况下,它不会计算
元素.ID==strFieldId
?是否预期
m_dynamiccheckbox列表
将有空元素?
Array.Find(m_dynamiccheckbox列表,element=>element!=null&&element.ID==strfieldd)?是否预期
m_dynamiccheckbox列表
将包含空元素?