CodeTypeDeclaration.BaseTypes Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the base types of the type.
public:
property System::CodeDom::CodeTypeReferenceCollection ^ BaseTypes { System::CodeDom::CodeTypeReferenceCollection ^ get(); };
public System.CodeDom.CodeTypeReferenceCollection BaseTypes { get; }
member this.BaseTypes : System.CodeDom.CodeTypeReferenceCollection
Public ReadOnly Property BaseTypes As CodeTypeReferenceCollection
Property Value
A CodeTypeReferenceCollection object that indicates the base types of the type.
Remarks
To generate a class in Visual Basic that does not inherit from a base type, but that does implement one or more interfaces, you must include Object as the first item in the BaseTypes collection.
Note
In the .NET Framework version 2.0 you do not need the CodeTypeReference for Object if the interface you are implementing already exists and you are referring to it by type. For example, if you are implementing the ICollection interface and add it to the collection with this statement, ctd.BaseTypes.Add(New CodeTypeReference(typeof(ICollection)))
, you do not need the preceding ctd.BaseTypes.Add(New CodeTypeReference(GetType(Object)))
statement.
The following code illustrates the addition of a CodeTypeReference to the collection that refers to Object.
Dim ctd As New CodeTypeDeclaration("Class1")
ctd.IsClass = True
ctd.BaseTypes.Add(New CodeTypeReference(GetType(Object)))
ctd.BaseTypes.Add(New CodeTypeReference("Interface1"))
CodeTypeDeclaration ctd = new CodeTypeDeclaration("Class1");
ctd.IsClass = true;
ctd.BaseTypes.Add(new CodeTypeReference(typeof(Object)));
ctd.BaseTypes.Add(new CodeTypeReference("Interface1"));
The preceding code generates the equivalent of the following Visual Basic code.
Public Class Class1
Implements Interface1
However, the Visual Basic code actually generated is the following.
Public Class Class1
Inherits Object
Implements Interface1
Applies to
See also
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기