LoginSignup
4
4

More than 5 years have passed since last update.

数値型メンバーを0、参照型メンバーをnullで初期化した構造体を取得する

Posted at

default(Type)を使う。

struct hogehoge {
  string s;
}

struct hoge {
  int i;
  string s;
  hogehoge hh;
}

hoge h = default(hoge);

数値型に対しては 0、 参照型に対しては null。
構造体に対しては、 構造体の全てのメンバーに対して 0 または null で初期化したものを与える。

ジェネリックス

4
4
0

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
4