c# - Visual Studio 2010 (C#) : Blank before and after * when multiplying

标签 c# visual-studio-2010 formatting settings code-formatting

我在编写 C# 时注意到 Visual Studio 2010 中的一个奇怪行为。当我打字时

var x = 2 * 5

然后输入';' VS 将行更改为

var x = 2*5;

所以它删除了空白。另一方面,如果我在该行中执行 CTRL+X 和 CTRL+V,则会再次插入空格;

var x = 2 * 5;

这在使用像 SVN 这样的工具时非常烦人,因为它使得跟踪代码中的实际 更改变得更加困难。我看着

工具->选项->文本编辑器->C#->格式化->间距

但找不到合适的。你们有人知道如何统一行为吗?

谢谢,

亨德里克

最佳答案

在菜单中:

工具 > 选项 > 文本编辑器 > C# > 格式化 > 间距

转到 Set spacing for operators 并选择 Insert space before and after binary operators

enter image description here

另外,如果您使用像 ReSharper 这样的扩展名,确保它们的配置方式与 Visual Studio 本身相同。

关于c# - Visual Studio 2010 (C#) : Blank before and after * when multiplying,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14643273/

相关文章:

c# - 为什么使用 Fiddler 时 HttpWebRequest 对象的性能会提高?

c# - 使用 BouncyCaSTLe 生成 HMAC-SHA256 哈希

c# - Web API 返回转义的 JSON

c# - 将图像添加到 ImageList 后出现编译错误 RG0000 ("incorrect format")

visual-studio-2010 - 每次在 VS 2010 上发布之前如何提交 SVN

c# - Win窗体调用t4模板并在VS2010中传递参数

python - 为什么不同的格式方法在 Python 中表现不同?

Eclipse C++ 格式化程序在方法标识符之前放置新行

c# - 理解 Expression.Invoke() 方法

C# 字符串格式标志或修饰符到小写参数