Generics in CodeDom of .NET 2.0?

N

Nicholas Paldino [.NET/C# MVP]

Mark,

Check the TypeParameters property of the CodeTypeDeclaration class. It
represents the type parameters that the type has. I'm pretty sure that your
method declaration class instance has the same property exposed as well.

Hope this helps.
 
M

Mark

Excellent. This inspired me to dig further, and I succeeded with the
following:

CodeTypeDeclaration newClass = new CodeTypeDeclaration("MyCollectionClass");
newClass.BaseTypes.Add( new CodeTypeReference("Collection",
new CodeTypeReference[] {
new
CodeTypeReference("MyBaseClass")
}));

// This results in code like:

public class MyCollectionClass : Collection<MyBaseClass>
{
//woo hoo!
}


Nicholas Paldino said:
Mark,

Check the TypeParameters property of the CodeTypeDeclaration class. It
represents the type parameters that the type has. I'm pretty sure that your
method declaration class instance has the same property exposed as well.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


Mark said:
I'm looking at the CodeDom namespace in .NET 2.0 class library online
(http://msdn2.microsoft.com/library/za6cc751.aspx). I'm not seeing any
class that would allow me to create Generics. Any suggestions?

Thanks in advance.

Mark
 
M

Mark

Excellent. This inspired me to dig further, and I succeeded with the
following:

CodeTypeDeclaration newClass = new CodeTypeDeclaration("MyCollectionClass");
newClass.BaseTypes.Add( new CodeTypeReference("Collection",
new CodeTypeReference[] {
new
CodeTypeReference("MyBaseClass")
}));

// This results in code like:

public class MyCollectionClass : Collection<MyBaseClass>
{
//woo hoo!
}


Nicholas Paldino said:
Mark,

Check the TypeParameters property of the CodeTypeDeclaration class. It
represents the type parameters that the type has. I'm pretty sure that your
method declaration class instance has the same property exposed as well.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


Mark said:
I'm looking at the CodeDom namespace in .NET 2.0 class library online
(http://msdn2.microsoft.com/library/za6cc751.aspx). I'm not seeing any
class that would allow me to create Generics. Any suggestions?

Thanks in advance.

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

Similar Threads


Top