Linq FirstOrDefault Null Exception Handling

  • Thread starter Thread starter Shan1986
  • Start date Start date
S

Shan1986

Guest
Hallo,

I have a class equipment and it has a custom object "Type" and Type has "Material". If Type does not have any material then i get null exception. How do i handle it. If type has material then it works without any problem.

Dim str_MID As String = EQIP.Item(vt_cbx_eq.SelectedIndex).Type.ToList.Item(0).Material.FirstOrDefault.MID.ToString
Thanks

Continue reading...
 
Back
Top