2008-09-27

巢狀 using 排版

原來的格式

using (Rijndael aes = RijndaelManaged.Create())
{
    using (ICryptoTransform cryptor = aes.CreateEncryptor(rgbKey, rgbIV))
    {
        using (CryptoStream cs = new CryptoStream(output, cryptor, CryptoStreamMode.Write))
        {
            byte[] buf = new byte[8192];
            for (int len = 0; (len = input.Read(buf, 0, buf.Length)) > 0; )
            {
                cs.Write(buf, 0, len);
            }
        }
    }
}

調整後的格式

using (Rijndael aes = RijndaelManaged.Create())
using (ICryptoTransform cryptor = aes.CreateEncryptor(rgbKey, rgbIV))
using (CryptoStream cs = new CryptoStream(output, cryptor, CryptoStreamMode.Write))
{
    byte[] buf = new byte[8192];
    for (int len = 0; (len = input.Read(buf, 0, buf.Length)) > 0; )
    {
        cs.Write(buf, 0, len);
    }
}

調整後的程式是不是比較美呢!

 

keywords: c#, coding style

沒有留言: