using System;
namespace Datentypen
{
internal class Program
{
static void Main(string[] args)
{
IntegerVorzeichenLos();
Console.WriteLine();
IntegerMitVorzeichen();
Console.WriteLine();
Gleitkommazahlen();
Console.WriteLine();
Festkommazahlen();
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
Console.Write(("Beenden mit beliebiger Taste ..."));
Console.ReadKey(true);
}
///
/// Auflistung der vorzeichenlosen Ganzzahl-Tpyen
///
static void IntegerVorzeichenLos()
{
Console.WriteLine("Nichtnegative Ganzzahlen");
Console.WriteLine("------------------------");
string format = "{0,-10}{1,-15}{2,14}{3,7}{4,28}";
string iF = ("#,0");
Console.WriteLine(format, "Typ", ".NET-Datentyp", "z.B.", "Von", "Bis");
{
byte zahl = 13;
Console.WriteLine(format, "byte", zahl.GetType(), zahl.ToString(iF), byte.MinValue.ToString(iF), byte.MaxValue.ToString(iF));
}
{
ushort zahl = 1000;
Console.WriteLine(format, "ushort", zahl.GetType(), zahl.ToString(iF), ushort.MinValue.ToString(iF), ushort.MaxValue.ToString(iF));
}
{
uint zahl = 123456;
Console.WriteLine(format, "uint", zahl.GetType(), zahl.ToString(iF), uint.MinValue.ToString(iF), uint.MaxValue.ToString(iF));
}
{
ulong zahl = 123456789;
Console.WriteLine(format, "ulong", zahl.GetType(), zahl.ToString(iF) + " UL", ulong.MinValue.ToString(iF), ulong.MaxValue.ToString(iF));
}
}
///
/// Auflistung der Ganzzahl-Tpyen mit Vorzeichen (Positiv/Negativ)
///
static void IntegerMitVorzeichen()
{
Console.WriteLine("Positive/negative Ganzzahlen");
Console.WriteLine("----------------------------");
string format = "{0,-10}{1,-15}{2,14}{3,28}{4,28}";
string iF = ("#,0");
Console.WriteLine(format, "Typ", ".NET-Datentyp", "z.B.", "Von", "Bis");
{
sbyte zahl = -13;
Console.WriteLine(format, "sbyte", zahl.GetType(), zahl.ToString(iF), sbyte.MinValue.ToString(iF), sbyte.MaxValue.ToString(iF));
}
{
short zahl = -13;
Console.WriteLine(format, "short", zahl.GetType(), zahl.ToString(iF), short.MinValue.ToString(iF), short.MaxValue.ToString(iF));
}
{
int zahl = -13;
Console.WriteLine(format, "int", zahl.GetType(), zahl.ToString(iF), int.MinValue.ToString(iF), int.MaxValue.ToString(iF));
}
{
long zahl = -13;
Console.WriteLine(format, "long", zahl.GetType(), zahl.ToString(iF) + " L", long.MinValue.ToString(iF), long.MaxValue.ToString(iF));
}
}
///
/// Auflistung der Gleitkommazahlen
///
static void Gleitkommazahlen()
{
Console.WriteLine("Gleitkommazahlen");
Console.WriteLine("----------------");
string format = "{0,-10}{1,-15}{2,14}{3,28}{4,28}";
Console.WriteLine(format, "Typ", ".NET-Datentyp", "z.B.", "Von", "Bis");
{
float zahl = 1234567.89F;
Console.WriteLine(format, "float", zahl.GetType(), zahl.ToString() + "F", float.MinValue.ToString(), float.MaxValue.ToString());
}
{
double zahl = 0.1234567D;
Console.WriteLine(format, "double", zahl.GetType(), zahl.ToString() + "D", double.MinValue.ToString(), double.MaxValue.ToString());
}
}
///
/// Auflistung der Ferstkommazahlen
///
static void Festkommazahlen()
{
Console.WriteLine("Festkommazahlen");
Console.WriteLine("---------------");
string format = "{0,-10}{1,-15}{2,14}{3,35}{4,35}";
Console.WriteLine(format, "Typ", ".NET-Datentyp", "z.B.", "Von", "Bis");
{
decimal zahl = 123456.789M;
Console.WriteLine(format, "decimal", zahl.GetType(), zahl.ToString() + "M", decimal.MinValue.ToString(), decimal.MaxValue.ToString());
}
}
}
}