Stacking "using" blocks together
I had always been thinking of using the using-block to instantiate multiple disposable objects so I don't have to remember explicitly calling Close() or Dispose() on them:
using (IDisposable one = new DisposableOne(),
IDisposable two = new DisposableTwo())
{
// Compile time error
}
But unfortunately C# does not support that. So as a work around, one would do these nested using statements to do the trick:
using (IDisposable one = new DisposableOne())
{
using (IDisposable two = new DisposableTwo())
{
// Ops. Code is now indented
}
}
But now, you have messed up your pretty-looking indentation of your code. Remember back in the acadamia your programming class instructor told you that all your if-else/for/while statements will work without curly brackets? Well, surprise, same case for using blocks:
using (IDisposable one = new DisposableOne())
using (IDisposable two = new DisposableTwo())
{
// This works!
}
Time to show off to your pairing friend you can write prettier code than him/her =D
1 comment:
夫の浮気 相談
浮気 相談
企業調査 相談
身上調査 相談
所在調査 相談
不倫調査 相談
盗聴調査 相談
池袋 風俗
渋谷 風俗
新宿 風俗
性病検査 女性
大人のおもちゃ
アダルトDVD
av 写真
大人のおもちゃ
アダルトグッズ
アダルトグッズ
アダルト ブルーレイ
アンドロペニス
オナホール
コンドーム
ローション
SM 通販
メンズセクシー下着
男性用下着
Tバック下着
大規模修繕
決済代行
SEO
SEO
花植物大図鑑
決済代行
ブライダルエステ
FX 初心者
クレジットカード 申込
Post a Comment