4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

DataRowからの値の取り出しについての備忘録

Last updated at Posted at 2018-10-26

VB.NETにはnull合体演算子がなく
スマートな書き方に悩みましたのでメモ書き。

if二項演算子で似たようにセーフティな取り出しが実現できます。

DataRow.cs
int id = dr.Field<int?>("id")?? 0
DataRow.vb
Dim id As Integer = If(dr.Field(Of Integer?)("id"), 0)

参考

[C#][VB.NET] NULLの扱い(NULL合体演算子とNULL条件演算子)
DataRowの値を取り出すときにDBNullでエラーを出さない

4
2
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?