为什么省略花括号被认为是一种不好的做法?
if (foo) Bar();//orfor(int i = 0 i < count; i++) Bar(i);
using (Brush br = new SolidBrush(Color.FromArgb(15, GlowColor))){
for (int x = 0; x <= GlowAmount; x++)
{
for (int y = 0; y <= GlowAmount; y++)
{
g.DrawString(Text, this.Font, br, new Point(IconOffset + x, y));
}
}
}
//versususing (Brush br = new SolidBrush(Color.FromArgb(15, GlowColor)))
for (int x = 0; x <= GlowAmount; x++)
for (int y = 0; y <= GlowAmount; y++)
g.DrawString(Text, this.Font, br, new Point(IconOffset + x, y));usings
using (Graphics g = Graphics.FromImage(bmp)){
using (Brush brush = new SolidBrush(backgroundColor))
{
using (Pen pen = new Pen(Color.FromArgb(penColor)))
{
//do lots of work
}
}
}//versususing (Graphics g = Graphics.FromImage(bmp))using (Brush brush = new SolidBrush(backgroundColor))using (Pen pen = new
Pen(Color.FromArgb(penColor))){
//do lots of work}if (foo) Bar(); Biz();
qq_笑_17
慕沐林林
汪汪一只猫
随时随地看视频慕课网APP
相关分类