简体   繁体   English

Visual Studio 2010 - C#编辑器比VB.NET编辑器更麻烦

[英]Visual Studio 2010 - C# editor more cumbersome than VB.NET editor

I traditionally work in VB.NET, but have been asked to code the latest project in C#. 我传统上使用VB.NET,但已被要求用C#编写最新项目。

This is fine as I can work in either language, having had to frequently translate C# code to VB in the past and I've no qualms about developing in either. 这很好,因为我可以用任何一种语言工作,过去不得不经常将C#代码翻译成VB,而且我也没有任何关于开发的问题。

My issue is with the Visual Studio editor and how many of the tasks that have traditionally been automated for me while writing VB.NET code are missing when writing C# code, or involve a larger variety of key-presses. 我的问题在于使用Visual Studio编辑器,在编写C#代码时,或者涉及更多种类的按键时,编写VB.NET代码时传统上为我自动完成的任务有多少。

For example, creating a new #region or function... 例如,创建一个新的#region或函数......

In VB.NET creating a region involves typing # + r , at which point intellisense kicks in and shows me #Region . 在VB.NET中创建一个区域涉及键入 + r ,此时intellisense启动并向我显示#Region I press space and #Region is auto-completed, thus allowing me to type the region name, then click Enter and the closing #End Region is automagically added. 我按下空格并自动完成#Region ,这样我就可以输入区域名称,然后点击Enter键 ,自动添加结束#End Region

In C#, I type # + r ... and nada.. I have to either click Ctrl + k + x and select #Region from the list of snippets to achieve the same effect. 在C#中,我键入 + r ...和nada ..我必须单击Ctrl + k + x并从片段列表中选择#Region以达到相同的效果。

Similarly when writing functions in VB.NET ... the autocomplete creates the structure in seconds, whereas C# involves having to manually add the brackets etc, adding precious seconds to the development process. 类似地,当在VB.NET中编写函数时...自动完成在几秒钟内创建结构,而C#涉及必须手动添加括号等,为开发过程增加了宝贵的秒数。 (or perhaps there is another shortcut key combo) (或者可能还有另一个快捷键组合)

These are just two examples, but there are many others where the short-cuts that the VB.NET editor provides make coding much faster than the C# editor. 这只是两个例子,但是还有很多其他的例子,VB.NET编辑器提供的快捷方式使得编码比C#编辑器快得多。 I'm pretty shocked actually as C# is so often lauded for being "better" than VB.NET. 我很震惊,因为C#经常因为比VB.NET“更好”而受到称赞。

Anyway rant over. 无论如何都在咆哮。

My question is, are there any plugins which allow autocomplete on the C# editor in the same way as provided to the VB.NET editor? 我的问题是,是否有任何插件允许在C#编辑器上以与提供给VB.NET编辑器相同的方式自动完成?

ReSharper的................................................. ........................

I think you're just used to coding in VB.NET. 我想你只是习惯于在VB.NET中编码。 As for your comment about C# being viewed as superior to VB.NET, I think you need to make a distinction between the language and the editor, because the two are not intrinsically tied together. 至于你对C#被认为优于VB.NET的评论,我认为你需要区分语言和编辑器,因为这两者并没有内在联系在一起。

It's possible that C# doesn't offer the same auto-completion features that VB.NET does, but I think productivity comes down to how comfortable you are with the language. C#可能不提供与VB.NET相同的自动完成功能,但我认为生产力取决于您对语言的满意程度。 Even without those auto-completion features, I can code a heck of a lot faster in C# than I can in VB.NET, and that's because I'm used to how C# behaves, and I know how to flow with the editor. 即使没有这些自动完成功能,我也可以在C#中编写比在VB.NET中更快的代码,这是因为我已经习惯了C#的行为方式,并且我知道如何使用编辑器。

In my honest opinion, I think you need to get used to coding in C# before you can make a true assessment of how coding in either language impacts your productivity. 在我看来,我认为你需要习惯用C#编码才能真正评估两种语言中的编码如何影响你的工作效率。

EDIT 编辑

If you're looking for something free that's comparable to Resharper, I would suggest taking a look at CodeRush Xpress . 如果你正在寻找与Resharper相当的免费软件,我建议你去看看CodeRush Xpress There's also a full-featured version of CodeRush that retails around $100 cheaper than Resharper. 还有一个功能齐全的CodeRush版本,比Resharper便宜零售价约100美元。

Sounds like you need to do some digging around under Tools... Options > Text Editor > C# and check the configuration there. 听起来你需要在工具...选项>文本编辑器> C#下进行一些挖掘并检查那里的配置。 Some things can be tuned from there that may have been missed if you configured if you setup your environment as VB.NET initially. 如果您配置了最初将环境设置为VB.NET,那么可以从那里调整一些可能已经错过的东西。

You might also look into the Visual Studio Power Tools which have some extra auto-complete bracket options available to it, as well as a few other features that could help. 您还可以查看Visual Studio Power Tools ,它具有一些额外的自动完整支架选项,以及一些其他可能有用的功能。

ReSharper为Visual Studio为VB.NET免费提供的C#做了很多工作。

Here's a code snippet for inserting a private method: 这是用于插入私有方法的代码段:

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <CodeSnippet Format="1.0.0">
        <Header>
            <Title>Private Method</Title>
            <Shortcut>pvtm</Shortcut>
            <Description>Code snippet for a private method</Description>
            <Author>Your Name Here</Author>
            <SnippetTypes>
                <SnippetType>Expansion</SnippetType>
            </SnippetTypes>
        </Header>
        <Snippet>
            <Declarations>
                <Literal>
                    <ID>type</ID>
                    <ToolTip>Return Type</ToolTip>
                    <Default>void</Default>
                </Literal>
                <Literal>
                    <ID>name</ID>
                    <ToolTip>Method name</ToolTip>
                    <Default>MyMethod</Default>
                </Literal>
            </Declarations>
            <Code Language="csharp"><![CDATA[private $type$ $name$ ()
    {
        $selected$ $end$
    } //end method $name$]]>
            </Code>
        </Snippet>
    </CodeSnippet>
</CodeSnippets>

I'm sure it can be improved, but then you can just type pvtm and hit tab and voila! 我敢肯定它可以改进,但是你可以输入pvtm然后点击tab并瞧! You get a whole method. 你得到一个完整的方法。 Again, not the same as the VB editor, but pretty close. 同样,与VB编辑器不一样,但非常接近。 Some might say better. 有人可能会说更好。

This is an old snippet and I think it will work in VS2010, but I haven't tried it. 这是一个旧片段,我认为它可以在VS2010中使用,但我还没有尝试过。

I'm a big proponent of CodeRush from DevExpress , which serves largely a similar purpose to Resharper. 我是DevExpress的CodeRush的忠实拥护者,它主要与Resharper有着相似的目的。 In Code Rush, if I want to put in a region, I select the code I want to region off and hit Ctrl-3, and the regioning is created with a caret on the region name that then type in. Its behavior is also very configurable regarding all of its templates (which are like VS Code Snippets on steroids). 在Code Rush中,如果我想放入一个区域,我选择要关闭区域的代码并按Ctrl-3,然后在区域名称上创建区域,然后输入。它的行为也非常可配置其所有模板(类似于类固醇上的VS Code Snippets)。

Full disclosure, though -- it's an investment because the express version has very little functionality as of Visual Studio 2010. You'd also do either this or ReSharper -- probably not both. 但完全披露 - 这是一项投资,因为快递版本在Visual Studio 2010中的功能非常少。您也可以使用此功能或ReSharper - 可能不是两者兼而有之。 I had both installed at one point and I seem to recall them not playing very nicely together. 我曾经安装过两次,我似乎记得他们不能很好地一起玩。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM