0
0

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 3 years have passed since last update.

staticの使い方

Posted at

staticの使い方について今日初めて知ったので忘備録としてまとめます。

staticとは?

静的メンバーを作成する際に使用する。
staticをしようすることでインスタンス生成のたびにメモリ領域が確保されるのではなく、アプリでただ1つのメモリ領域が確保される。
変数とメソッド両方に使用可能。

静的メンバー

変数やメソッドをインスタンス単位で生成するのではなく、アプリに一つだけ生成したい場合に使用する。

使い方

クラスのインスタンスを生成するのではなく、クラス名にドットを付けて直接呼び出せる。

参考記事
C#初心者のための基礎!staticスタティックの意味と使い方を解説#25

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?