-2

I am getting a datatype in code as "int32" however, what I actually need is the full name, "integer". Is this possible?

Here's the code for the data type:

public static List<Parameter> GetParameterMembers(Type parameterType)
{
    var parameterList = new List<Parameter>();

    var returnTypeFields = parameterType.IsArray ? ((TypeInfo)parameterType.GetElementType()).DeclaredFields : ((TypeInfo)parameterType).DeclaredFields;

    returnTypeFields.ToList().ForEach(item =>
    {
        if (item.MemberType != MemberTypes.Field) return;

        parameterList.Add(new Parameter
        {
            Name = item.Name,
            Parameters = item.FieldType.IsClass && !IsNativeType(((FieldInfo)item).FieldType) ? GetParameterMembers(((FieldInfo)item).FieldType) : new List<Parameter>(),
            DataType = item.FieldType.Name
        });
    });

    return parameterList;
}
Rand Random
  • 7,300
  • 10
  • 40
  • 88
John
  • 263
  • 1
  • 15
  • 5
    There is no built-in data type with the name "integer" in .NET. – Chris Pickford May 23 '18 at 08:47
  • Why do you need the "full name" - I suspect this means there's more context you aren't telling us. Is this relevant: https://stackoverflow.com/questions/9696660/what-is-the-difference-between-int-int16-int32-and-int64/9696700 – doctorlove May 23 '18 at 08:49
  • 1
    `integer` isn't a .NET type and it's not even a C# data type. If you were going to get the native data type then you'd get "int", not "integer". If you were running VB code then you might have some justification for getting "Integer" but that doesn't really make sense anyway because the VB and C# code both get compiled to the same IL code and, even if it knew about your VB or C# source, it wouldn't know whether you used the .NET type or the native alias in your original code. As @doctorlove suggests though, explain what you're trying to achieve rather than how you're trying to achieve it. – jmcilhinney May 23 '18 at 08:51
  • Unclear what you are asking – TheGeneral May 23 '18 at 09:00
  • What are the *full name*s for `Int16`, `Int64`? Do they still *integers*? – Dmitry Bychenko May 23 '18 at 09:13
  • Thanks @ChrisPickford – John May 23 '18 at 11:24

1 Answers1

0

You'll have to map them and translate it yourself. The closest to 'Integer' is the vb datatype, which is a short-hand for 'the biggest bitrate int the system can handle', similar to 'int' from c#

Davesoft
  • 724
  • 1
  • 4
  • 10