When looking at disassembled .NET assemblies I notice that constructors are defined as ".ctor". Is that possible to do in the actual code?
Damn ... it is much easier to use that in code snippets
Nick Brooks
2010-04-11 20:32:18
+2
A:
This is only a syntactic difference between C# and IL. You need to call out the class name when defining the constructor in your C# code. What are you looking to accomplish?
Michael Petrotta
2010-04-11 20:32:20
Can't be bothered to type the class name, or to answer? Can't say I'm with you on either one.
Michael Petrotta
2010-04-11 20:36:40
+3
A:
Dont see the point why you want this.
You can use the VS snippet ctor and you get a free constructor.
Just type ctor and press two times the tab-key.
Henri
2010-04-11 20:36:48
+3
A:
RE:
Damn ... it is much easier to use that in code snippets
Is this for Visual Studio code snippets? They already have one called ctor that substitutes the class name. You could look at the definition of that if its default behaviour is not what you want.
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>ctor</Title>
<Shortcut>ctor</Shortcut>
<Description>Code snippet for constructor</Description>
<Author>Microsoft Corporation</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal Editable="false">
<ID>classname</ID>
<ToolTip>Class name</ToolTip>
<Function>ClassName()</Function>
<Default>ClassNamePlaceholder</Default>
</Literal>
</Declarations>
<Code Language="csharp"><![CDATA[public $classname$ ()
{
$end$
}]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Martin Smith
2010-04-11 20:39:17