So I\'m building an application that is going to do a ton of code generation with both C# and VB output (depending on project settings).
I\'ve got a CodeTemplateEngi
You can do this using CodeDom's support for generic types and the GetTypeOutput method:
CodeTypeReference ctr;
if (/* you want to output this as nullable */)
{
ctr = new CodeTypeReference(typeof(Nullable<>));
ctr.TypeArguments.Add(new CodeTypeReference(typeName));
}
else
{
ctr = new CodeTypeReference(typeName);
}
string typeName = codeDomProvider.GetTypeOutput(ctr);
This will respect language-specific type keywords such as C# int or VB Integer, though it will still give you System.Nullable rather than int?.