Get user-friendly name of simple types through reflection?
c#, reflection, types
Solution
using CodeDom;
using Microsoft.CSharp;
// ...
Type t = typeof(bool);
string typeName;
using (var provider = new CSharpCodeProvider())
{
var typeRef = new CodeTypeReference(t);
typeName = provider.GetTypeOutput(typeRef);
}
Console.WriteLine(typeName); // bool
Problem
``` Type t = typeof(bool); string typeName = t.Name; ``` In this simple example, `typeName` would have the value `"Boolean"`. I'd like to know if/how I can get it to say `"bool"` instead. Same for int/Int32, double/Double, string/String.