LoginSignup
0

More than 5 years have passed since last update.

CastとOfType

Posted at

Listの個々の要素をキャストするメソッドにCastとOfTypeがある。

Cast

キャストできない場合は例外である System.InvalidCastException を返す。

OfType

Listから指定された型に一致する要素のみを取り出す。取り出すことができた要素はその型になる。キャストできなくても、例外を返さない点がCastと異なる。

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
0