本文介绍了C#约定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚意识到使用大括号的C#约定是在定义块的第一行后立即放置

左大括号

(类声明除外)像这样:


if(something){

stuff

}


这是为什么?有很多人这样做吗?似乎把支撑放在

单独的行上更好更容易阅读。在这本书中,我是一个读书的b $ b,它表示闭合支架与

第一行(如上所述)排列非常重要,我想是的可读性,但这是多么常见

这个?这看起来并不可读:


if(something)

{

stuff

}

I just realized that the C# convention for uses braces is to put the
opening brace immediately after the first line that defines the block
(except for class declarations) like this:

if (something) {
stuff
}

Why is that? Do a lot of people do this? It seems like putting braces on
separate lines is much nicer and easier to read. In the book I''m
reading, it says it''s important that the closing brace line up with the
first line (like above), I guess for readability, but how common is
this? It doesn''t seem as readable as this:

if (something)
{
stuff
}

推荐答案





根据我的经验,这比前者(K& R)

支撑更为常见。


-

Jon Skeet - < sk *** @ pobox.com>
博客:

如果回复该群组,请不要给我发邮件



In my experience, this is far more common than the former (K&R)
bracing.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too





哦不,我做了什么!? :)



Oh no, what did I do!? :)


这篇关于C#约定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 03:39