class TypeInfo
{
public string Name { get; }
public object MinValue { get; }
public object MaxValue { get; }
public int InstanceSize { get; }
public TypeInfo(Type type)
{
// validation...
Name = type.FullName;
InstanceSize = Marshal.SizeOf(type);
MinValue = type.GetField("MinValue").GetValue(null);
MaxValue = type.GetField("MaxValue").GetValue(null);
}
}
static void Main()
{
var typeNames = new[] { "Int32", "Double", "UInt16" };
var rows = typeNames
.Select(typeName => Type.GetType($"System.{typeName}")!) // можно объединить в 1
.Select(type => new TypeInfo(type)) //
.Select(typeInfo => $@"{typeInfo.Name.Substring(7),-8}
{typeInfo.Size,4} {typeInfo.MinValue,30} {typeInfo.MaxValue,30}");
Console.WriteLine($"{"Name",-8} Size {"MinValue",30} {"MaxValue",30}");
foreach (var row in rows)
Console.WriteLine(row);
}