简体   繁体   English

在 Visual Stuido 2019 中添加 lambda/func 箭头运算符 => 是否有任何快捷方式?

[英]Is there any shortcut to add the lambda/func arrow operator => in Visual Stuido 2019?

It's really a simple thing, ReSharper did it for me when I was writing a lambda expression, but I stopped using ReSharper and would like to know if there is any way to auto-complete a lambda or func operation with the =>这真的是一件简单的事情,ReSharper 在我编写 lambda 表达式时为我完成了它,但我停止使用 ReSharper 并想知道是否有任何方法可以自动完成 lambda 或 func 操作=>

builder.HasKey(m => m.Id);

Following the @Sajeetharan tip, I created this snippet, but I would like to use it in a more simple way, I need to press tab 2 times and after that press enter, I'm not sure if it is efficient at all, almost returning to resharper for these little things按照@Sajeetharan 的提示,我创建了这个片段,但我想以更简单的方式使用它,我需要按两次制表符,然后按回车键,我不确定它是否有效,几乎为这些小事返回 reshaper

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <CodeSnippet Format="1.0.0">
        <Header>
            <Title>lambda</Title>
            <Shortcut>lambda</Shortcut>
            <Description>Code snippet for lambda</Description>
            <Author>Nestorzin</Author>
            <SnippetTypes>
                <SnippetType>Expansion</SnippetType>
            </SnippetTypes>
        </Header>
        <Snippet>
            <Declarations>
                <Literal>
                  <ID>Name</ID>
                  <Default>r</Default>
                </Literal>
            </Declarations>
            <Code Language="csharp"><![CDATA[$Name$ => $Name$$end$]]>
            </Code>         
        </Snippet>
    </CodeSnippet>
</CodeSnippets>

There is NO shortcut available.没有可用的NO方式。 Certainly you can define one code snippet and insert,当然,您可以定义一个代码片段并插入,

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <CodeSnippet Format="1.0.0">
        <Header>
            <Title>lambda</Title>
            <Shortcut>lambda</Shortcut>
            <Description>Code snippet for lambda statement</Description>
            <Author>Bestorzin</Author>
            <SnippetTypes>
                <SnippetType>Expansion</SnippetType>
                <SnippetType>SurroundsWith</SnippetType>
            </SnippetTypes>
        </Header>
        <Snippet>
            <Code Language="csharp"><![CDATA[(() =>
    {
        $selected$ $end$
    });]]>
            </Code>
        </Snippet>
    </CodeSnippet>
</CodeSnippets>

And save it on并将其保存在

C:\YourName\Documents\Visual Studio 201?\Code Snippets\Visual C#\My Code Snippets

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

相关问题 Visual Stuido 2019无法找到abd.exe - Visual stuido 2019 cant find abd.exe 在 Visual Studio 2019 中添加带有 css 类的 div 的键盘快捷键 - Keyboard shortcut to add a div with a css class in Visual Studio 2019 这个逻辑运算符有什么快捷方式吗? - Is there any shortcut for this logical operator? Lambda表达式里面? (如果是快捷方式)运算符 - Lambda expression inside ?? (if shortcut) operator 这个 Func 中的第一个箭头运算符是什么<t, treturn>意思是?</t,> - What does the first arrow operator in this Func<T, TReturn> mean? 是否有任何快捷方式将当前DateTime标记片段添加到Visual Studio中的c#文件 - Is there any shortcut to add current DateTime stamp snippet to c# file in Visual studio 无法在 Visual Studio 2019 Preview 和 Visual Studio 2019 中添加引用 - Unable to add references in Visual studio 2019 Preview and Visual Studio 2019 Visual Studio错误解决方法中的lambda与Func委托重载? - Visual Studio bug resolving lambda in method with Func delegate overloads? Visual 2019预览版是否存在任何兼容性问题? - are there any compatibility problems with Visual 2019 Preview? 如何在 Visual Studio 2019 中添加 .mdf 文件? - How to add .mdf file in Visual Studio 2019?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM