c# names for FCL Types

  • Thread starter Thread starter lennin
  • Start date Start date
L

lennin

Hello Everyone!

do you people know of any function in the framework to translate FCL
Type names of primitives to c# type names?. i.e. CSharp.GetName(
Type type )

CSharp.GetName( typeof(System.Int32)) == "int"
CSharp.GetName( typeof(System.Void)) == "void"


Thanks,

Lennin
 
do you people know of any function in the framework to translate FCL
Type names of primitives to c# type names?.

I think you can do it with the C# CodeDom support. But since there are
so few of them it's probably easier to use your own translation table.


Mattias
 
do you people know of any function in the framework to translate FCL
Type names of primitives to c# type names?

Yes.

private static string GetCsTypeName(CodeTypeReference type)
{
if (type == null)
throw new ArgumentNullException("type");
using (CodeDomProvider cs =
CodeDomProvider.CreateProvider("CSharp"))
return cs.GetTypeOutput(type);
}

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

Back
Top