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

csharp > クラスインスタンスの破棄 > スコープを抜ける

Last updated at Posted at 2016-08-22
動作環境
Unity 5.3.5-f1 on MacOS X El Capitan

関連 http://qiita.com/7of9/items/076cf5aaff7095bb876d

csvから読みこむデータをDataBaseManagerクラスで処理しようとした。

以下のコードでダミーテキストを取得できるようになった。

DataBaseManager.cs
using UnityEngine;
using System.Collections;


namespace NS_DataBaseManager
{
	public class DataBaseManager {
		public string getString() {
			return "test text";
		}
	}
}
InventoryCS.cs
DataBaseManager dbm = new DataBaseManager ();
T_about.text = dbm.getString ();

上記にてdbmをdeleteしようとしたが、deleteが見つからなかった。
以下の情報を見つけた。

インスタンスの破棄は、変数に null を代入することで行います(もしくはロジックのスコープを抜ける時)。

@yuba さんのコメントによると上記の例の場合はnullを入れる必要はなさそうです。

自分の過去記事で関連しそうなもの
csharp > using > 自動的にDispose()を呼び出してくれ、しかも、例外にも対応してくれる便利な構文

1
0
7

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
1
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?