C#Snippet:我们如何创建C#代码片段以将行包装到if条件中 [英] C# Snippet :how can we create C# code snippet to wrap a line into if condition

查看:70
本文介绍了C#Snippet:我们如何创建C#代码片段以将行包装到if条件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建C#片段,以便我可以将行包装到C#if条件。

I am trying to create C# snippet so that I can wrap line into C# if condition.

示例:

如果有代码行 喜欢这个

If there is line of code  likes this

  x!= y

  x!=y

  ---------- 

 ---------- 

将鼠标放在该行代码上,如果我应用C#代码段,然后它应该更改为这样

Keeping mouse on that line of code and if I apply C# snippet code, then it should change to like this

        if(x!= y)

        if(x!=y)

        {

       {

       }

       }

任何示例代码都会有所帮助。

Any sample code will real helps.

谢谢你,

~Kiran

推荐答案


您好,

Hi,

我正在尝试创建C#片段,以便我可以将行换行到C#条件。

I am trying to create C# snippet so that I can wrap line into C# if condition.

示例:

如果有代码行  ;喜欢这个

If there is line of code  likes this

  x!= y

  x!=y

  ---------- 

 ---------- 

将鼠标放在该行代码上,如果我应用C#代码段,然后它应该更改为这样

Keeping mouse on that line of code and if I apply C# snippet code, then it should change to like this

        if(x!= y)

        if(x!=y)

        {

       {

       }

       }

任何示例代码都会有所帮助。

Any sample code will real helps.

谢谢你,

~Kiran


Hi Kiran,



Visual Studio的功能类似于您的要求。



在C#类文件编辑器中,键入CTRL-K,然后键入X.
$


打开插入片段对话框。在对话框中,您可以使用向上和向下箭头进行导航,并使用Tab键选择您的选择。



在您的示例中,"将鼠标保持在行中并且应用C#片段"你按CTRL-K然后按X.
$


接下来你按下箭头直到你突出显示"Visual C#"。



接下来你按下箭头,直到你突出显示"if"和"if"。选项,然后按Tab键。



这将插入if片段并突出显示您要键入"x!= y"的区域。

$
谢谢你,



Hi Kiran,

Visual Studio has a functionality that is similar to what you are asking.

In a C# class file editor, type CTRL-K then X.

That open the insert snippet dialog. In the dialog you can navigate using your up and down arrows and select your choice with the Tab key.

On your example instead "keeping the mouse in the line and applying C# snippet" you would press CTRL-K then X.

Next you would press the arrow down until you highlight "Visual C#".

Next you would press the arrow down until you highlight the "if" option, and press Tab.

This will insert the if snippet and highlight the area where you would type "x!=y".

Thank you,



这篇关于C#Snippet:我们如何创建C#代码片段以将行包装到if条件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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