Visual Studio의 메서드에 대한 코드 조각
Visual Studio에서 예를 들어 입력 할 수 있습니다.
...에 대한 TAB TAB
코드 조각이 나타납니다.
비공개, 공개 등의 메소드에 대한 내장 코드 스 니펫도 있습니까?
ctor : 기본 생성자
소품 : 속성
propg : 읽기 전용 속성
sim : static int main
방법
svm : static void main
방법
여기에 좋은 목록이 있습니다 . 직접 만들고 싶다면 Snippet Designer 가 매우 좋습니다.
다음은 Visual Studio 2017 용 모든 Visual C # 코드 조각입니다.
메서드 조각을 Visual Studio Extension 으로 다운로드 할 수 있습니다 .
다음을 지원합니다.
method (typical method)
vmethod (virtual method)
smethod (static method)
xmethod (extension method)
Visual Studio에서 도구 → 확장 및 업데이트 메뉴로 이동합니다 .
확장 및 업데이트 창 관찰
검색 필드 (오른쪽 위)에 "C # Methods Code Snippets"를 입력합니다.
다음은 Visual Studio 2010 용 사용자 지정 코드 조각을 만드는 데 사용한 단계이지만 Visual Studio 2008에서도 작동합니다.
method.snippet 이라는 새 텍스트 파일을 만들고 다음을 붙여 넣습니다.
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>method</Title>
<Shortcut>method</Shortcut>
<Description>Code snippet for method</Description>
<Author>Kevin Hogg</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>methodname</ID>
<ToolTip>Method name</ToolTip>
<Function>MethodName()</Function>
<Default>MethodNamePlaceholder</Default>
</Literal>
</Declarations>
<Code Language="csharp"><![CDATA[public void $methodname$ ()
{
$end$
}]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Windows 탐색기의 snippets 폴더에 파일을 복사합니다.
- Visual Studio 2010 : C : \ Program Files (x86) \ Microsoft Visual Studio 10.0 \ VC # \ Snippets \ 1033 \ Visual C #
- Visual Studio 2008 : C : \ Program Files (x86) \ Microsoft Visual Studio 9.0 \ VC # \ Snippets \ 1033 \ Visual C #
파일을 저장하면 코드 조각이 자동으로로드되므로 이제 Visual Studio를 열고 다음을 입력 할 수 있습니다.
method<tab><tab>
* 여기서 <tab>은 Tab키보드 의 키입니다.
이제 이름을 변경할 수 있도록 MethodNamePlaceholder가 강조 표시된 다음이 생성 된 것을 볼 수 있습니다.
public void MethodNamePlaceholder()
{
}
사용 가능한 모든 목록을 보려면 다음을 수행하십시오 snippet
.
- 를 눌러 CTRL+K 후 CTRL+X
MSDN에서도 언급 한 내가 사용하는 일부 스 니펫은 다음과 같습니다.
- ' #if #if 지시문과 #endif 지시문을 만듭니다.
- ' #region #region 지시문 및 #endregion 지시문을 만듭니다.
- ~ 포함하는 클래스에 대한 소멸자를 만듭니다.
- attribute Attribute에서 파생되는 클래스에 대한 선언을 만듭니다.
- 체크 된 블록을 생성합니다.
- class 클래스 선언을 만듭니다.
- ctor 포함하는 클래스에 대한 생성자를 만듭니다.
- cw Creates a call to WriteLine.
- do Creates a do while loop.
- else Creates an else block.
- enum Creates an enum declaration.
- equals Creates a method declaration that overrides the Equals method defined in the Object class.
- exception Creates a declaration for a class that derives from an exception (Exception by default).
- for Creates a for loop.
- foreach Creates a foreach loop.
- forr Creates a for loop that decrements the loop variable after each iteration.
- if Creates an if block.
- indexer Creates an indexer declaration.
- interface Creates an interface declaration.
- invoke Creates a block that safely invokes an event.
- iterator Creates an iterator.
- iterindex Creates a "named" iterator and indexer pair by using a nested class.
- lock Creates a lock block.
- mbox Creates a call to MessageBox.Show. You may have to add a reference to System.Windows.Forms.dll.
- namespace Creates a namespace declaration.
- prop Creates an auto-implemented property declaration.
- propfull Creates a property declaration with get and set accessors.
- propg Creates a read-only auto-implemented property with a private "set" accessor.
- sim Creates a static int Main method declaration.
- struct Creates a struct declaration.
- svm Creates a static void Main method declaration.
- switch Creates a switch block.
- try Creates a try-catch block.
- tryf Creates a try-finally block.
- unchecked Creates an unchecked block.
- unsafe Creates an unsafe block.
- using Creates a using directive.
- while Creates a while loop.
I made my own snippet for a method. The XML code for it is the following, and you can add it to a file called "my_method.snippet" (or whatever_you_want.snippet) in C:\Users\YOUR_USERNAME\Documents\Visual Studio 2012\Code Snippets\Visual C#\My Code Snippets (your path might be different because I use VS2012):
<CodeSnippet Format="1.0.0">
<Header>
<Title>method</Title>
<Shortcut>method</Shortcut>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>access_modifier</ID>
<Default>private</Default>
</Literal>
<Literal>
<ID>return_type</ID>
<Default>void</Default>
</Literal>
<Literal>
<ID>name</ID>
<Default>New_method</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[$access_modifier$ $return_type$ $name$ ()
{
$end$
}]]>
</Code>
</Snippet>
</CodeSnippet>
You can create customs snippets. Like this:
http://www.mediafire.com/file/gz3tzjnydk5/meth.snippet
The code snippet for properties is:
propTABTAB
ReferenceURL : https://stackoverflow.com/questions/292164/code-snippets-for-methods-in-visual-studio
'Nice programing' 카테고리의 다른 글
ES6지도 객체를 정렬 할 수 있습니까? (0) | 2021.01.09 |
---|---|
해시 테이블의 기초? (0) | 2021.01.09 |
내장 된 가우스 함수를 사용하지 않고 이미지를 가우시안 블러 처리하려면 어떻게합니까? (0) | 2021.01.09 |
존재하지 않는 경우 디렉토리 생성 (0) | 2021.01.09 |
Interface Builder의 UILabel에 유니 코드 문자를 입력하는 방법은 무엇입니까? (0) | 2021.01.09 |