how to "implements an interface" using CodeDom

S

sql chen

'Hello
'i have generate such a simple class by CodeDom
'==========================================

Public Class A

Public Function B()

End Class

'==========================================
'But i want improve these code as follow:
'==========================================

Public Class A
Implements IData

Public Function B() implements IData.B

End Class

'==========================================

i tried "CodeTypeDeclaration.BaseTypes", but it can only let me "Inherits".
can you give me some good idea? thanks
 
G

Guest

sql chen said:
i tried "CodeTypeDeclaration.BaseTypes", but it can only let me "Inherits".

Well, the following code

Code:
typeDef as CodeTypeDeclaration = new CodeTypeDeclaration("SomeClass")
typeDef.BaseTypes.Add(new CodeTypeReference(typeof(IComparable)))
typeDef.BaseTypes.Add(new CodeTypeReference(typeof(Attribute)))

produces the output:

Code:
Public Class SomeClass
Implements System.IComparable
Inherits System.Attribute
End Class

Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top