Content deleted Content added
abbr: ctor Tags: Mobile edit Mobile app edit |
|||
Line 2:
{{ProgLangCompare}}
In [[class-based programming|class-based]] [[object-oriented programming]], a '''constructor''' (abbreviation: '''ctor''') in a [[Class (computer programming)|class]] is a special type of [[subroutine]] called to [[object creation|create an object]]. It prepares the new object for use, often accepting [[argument]]s that the constructor uses to set required [[member variable]]s.
'''Instance constructors''', sometimes referred to as '''.ctor''', are used to create and initialize any instance member variables when the new expression is used to create an object of a class. To initialize a static class, or static variables in a non-static class, a '''static constructor''' must be defined. Static constructors are sometimes referred to as '''.cctor'''.<ref>{{cite web|url=http://msdn.microsoft.com/en-us/library/k6sa6h87.aspx|title=Instance Constructors (C# Programming Guide) |publisher=Microsoft Developers Networks |accessdate=2014-04-05}}</ref><ref>{{cite book|url=http://books.google.com/books?id=oAcCRKd6EZgC&pg=PA222&lpg=PA222&dq=ctor+cctor&source=bl&ots=KAYfbDu_ay&sig=gLj6X9SpWXz86GHMvljkfb-D8Oc&hl=en&sa=X&ei=fUFAU--WJOewsASQ54GQAw&ved=0CGoQ6AEwCQ#v=onepage&q=ctor%20cctor&f=false |title=Expert .NET 2.0 IL Assembler |publisher=APress |date=2006-01-01|accessdate=2014-04-05}}</ref>
|