最終更新:2020-12-09 (水) 07:45:38 (1232d)
using
Top / using
補完
- Ctrl+.
usingを使う
using (FileStream fs = new FileStream("test.txt", FileMode.Read)) { using (StreamReader sr = new StreamReader(fs)) { // 処理する } }
usingを使わない
FileStream fs = new FileStream("test.txt", FileMode.Read); try { StreamReader sr = new StreamReader(fs); try { // 処理する } finally { if (sr != null) { sr.Dispose(); } } } finally { if (fs != null) { fs.Dispose(); } }
別名
using HogeHuga = Hoge.Huga;