我们使用大括号{}
作为变量表达式
NAME="test"
FILE_NAME=${NAME}file
Run Code Online (Sandbox Code Playgroud)
但我不明白我们在哪些场景中使用方括号()Say nslookup $(hostname)
仅适用于()
括号.
谁能解释一下?
我在这里看到了这个问题.我想知道以下缩进样式是否存在正式名称:
void fooBar(String s)
{
while (true)
{
// ... do something
}
}
Run Code Online (Sandbox Code Playgroud)
当左大括号与控制语句位于同一行时,其中的语句是缩进的,并且右大括号与控制语句位于同一缩进级别,该样式称为K&R-Style.那么上面这个代码示例的缩进样式是否有名称?
IE浏览器,这个:
if (x > 5)
return test;
Run Code Online (Sandbox Code Playgroud)
总是会变成:
if (x > 5)
{
return test;
}
Run Code Online (Sandbox Code Playgroud)
我不是在谈论大括号样式(Allman、GNU、Whiteman 等),我只是说完全有大括号。
有一些东西可以防止/启用单行控制语句,例如:
if (x > 5) return test;
这是AllowShortBlocksOnASingleLine
,但这不是我在这里寻找的东西。
如果它适用于 clang 7 那是理想的,但如果不是让我知道。
我怎样才能在Visual Studio 2008(C#)中的开括号和闭括号之间创建一条垂直线,如果你无法理解我在说什么,那就有下面的图片(Pic1).
[Pic1 - 我想用括号做这个] http://www.hanselman.com/blog/content/binary/vsbeforefonts.png
谢谢.
有谁知道键盘快捷方式从开始跳For
/ For Each
(或If
,While
等等)块的它在Visual Studio中结束时,如果你使用vb.net?我发现以下我认为可以工作但不会:在Visual Studio中找到匹配的Brace?
在评论之后,我检查了工具/选项/环境/键盘的Edit.GotoBrace
命令,该命令映射到瑞典语中的Ctrl+ å.
Vb.net本身不使用大括号,但在以下示例中:
For Each Foo in Bar
Do lots of stuff
Next
Run Code Online (Sandbox Code Playgroud)
我本以为同一个命令应该让我从For Each
"下一个" 跳到我,但它什么也没做.是否有另一个命令(或该命令应该工作但是本地有什么问题?)
vb.net for-loop keyboard-shortcuts braces visual-studio-2008
对于if语句之后的单行代码块有什么更好的编码实践 - 大括号还是没有大括号?只是为了避免太多"好吧,这取决于你使用的语言......"答案,让我们说C#.换句话说,哪个更好:
if(somecondition)
{
singleLineStatement;
}
Run Code Online (Sandbox Code Playgroud)
要么
if(somecondition)
singleLineStatement;
Run Code Online (Sandbox Code Playgroud) 如果你是一个记事本的++用户,你会明白我想让Xcode为我做什么,当我把光标放在大括号,圆括号和括号之前或之后时,我想要的非常简单,它突出了我的对,知道匹配的那些juste尝试将光标放在记事本++中并告诉我如何在Xcode中做到这一点我知道键盘右箭头的技巧和双击但是记事本++的技巧更快,提前谢谢
这条线是什么意思?
if ( ${fun("str1")} (fun("str2"), ${fun("str3")}) )
Run Code Online (Sandbox Code Playgroud)
使用str2的参数返回值和名称为return_value_for_str3的变量计算函数returning_value_for_str1_of_fun()_ name?
很多时候我的 if 条件只有一行,如下所示:
if (true)
// my single code
Run Code Online (Sandbox Code Playgroud)
但有时,我想将 if 条件扩展到 2 个或更多代码,所以我应该使用大括号。
if (true)
{
//do something
}
Run Code Online (Sandbox Code Playgroud)
我想知道是否有将第一个代码更改为第二个代码的快捷方式?
找不到使格式化程序将大括号放在同一行的方法。默认格式化程序似乎完全忽略与新行相关的所有设置。
有些人推荐 C# FixFormat 扩展,但现在它已被弃用并从市场上消失。我也找到了这个扩展,但它从一开始就清楚地表明它不会有帮助。
Before
public class ClassName {
public void CallMethod() {
this.LongUglyMethod("1234567890", "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
}
}
After
public class ClassName
{
public void CallMethod()
{
this.LongUglyMethod(
"1234567890",
"abcdefghijklmnopqrstuvwxyz",
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
);
}
}
Run Code Online (Sandbox Code Playgroud)
默认格式化程序似乎完全忽略这些设置。我试图把它们放在任何地方(正如这里所说的那样),但它只考虑与新行无关的所有内容。
{
"MSBuild": {
"UseLegacySdkResolver": true
},
"FormattingOptions": {
"NewLine": "\n",
"UseTabs": true,
"TabSize": 2,
"IndentationSize": 2,
"NewLinesForBracesInLambdaExpressionBody": false,
"NewLinesForBracesInAnonymousMethods": false,
"NewLinesForBracesInAnonymousTypes": false,
"NewLinesForBracesInControlBlocks": false,
"NewLinesForBracesInTypes": false,
"NewLinesForBracesInMethods": false,
"NewLinesForBracesInProperties": false,
"NewLinesForBracesInObjectCollectionArrayInitializers": false,
"NewLinesForBracesInAccessors": false,
"NewLineForElse": false,
"NewLineForCatch": false,
"NewLineForFinally": false …
Run Code Online (Sandbox Code Playgroud) braces ×10
c# ×4
formatting ×2
brackets ×1
clang-format ×1
coding-style ×1
curly-braces ×1
for-loop ×1
if-statement ×1
indentation ×1
matching ×1
notepad++ ×1
omnisharp ×1
parentheses ×1
php ×1
shell ×1
shortcut ×1
vb.net ×1
xcode ×1