你将如何格式化/缩进这段代码? [英] How would you format/indent this piece of code?

查看:144
本文介绍了你将如何格式化/缩进这段代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  int ID = Blahs.Add(new Blah(-1) ,-2,-3)); 

  int ID = Blahs.Add(new Blah(
1,2,3,55

);






编辑:



我的类实际上有很多参数,所以这可能会影响您的响应。

解决方案

我同意Patrick McElhaney;没有必要嵌套它....

  Blah aBlah = new Blah(1,2,3,55); 
int ID = Blahas.Add(aBlah);

这里有一些小优点:$ b​​
$ b


  1. 您可以在第二行设置一个断点并检查'aBlah'。

  2. 没有嵌套语句,您的差异将变得更清晰(变化更明显),例如创建新的Blah是在将其添加到列表中的独立声明中。


How would you format/indent this piece of code?

int ID = Blahs.Add( new Blah( -1, -2, -3) );

or

int ID = Blahs.Add( new Blah(
1,2,3,55
)          
); 


Edit:

My class has lots of parameters actually, so that might effect your response.

解决方案

I agree with Patrick McElhaney; there is no need to nest it....

Blah aBlah = new Blah( 1, 2, 3, 55 );
int ID = Blahas.Add( aBlah );

There are a couple of small advantage here:

  1. You can set a break point on the second line and inspect 'aBlah'.
  2. Your diffs will be cleaner (changes more obvious) without nesting the statements, e.g. creating the new Blah is in an independent statement from adding it to the list.

这篇关于你将如何格式化/缩进这段代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆