Autor Beitrag
paddy14
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 122



BeitragVerfasst: Di 01.03.11 16:40 
Guten tag forum,

eine frage, ich habe eine arrylis und diese ist mit werten gefüllt.
Type 1: double.
Type 2: string.

ich habe eine if Anweisung und dort will ich überprüfen ob es ein string ist.

Wie bekomme ich das hin welche befehle brauche ich.
bakachan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 503
Erhaltene Danke: 34

W7 (x64) Ultimate
C# / VB.NET (VS2010 Ultimate)
BeitragVerfasst: Di 01.03.11 16:52 
Dabei dürften dir die Funktionen GetType und typeof helfen.

Beispiel:
ausblenden C#-Quelltext
1:
2:
3:
object testObject = "bla";
if(testObject .GetType()==typeof(string))
Console.WriteLine("Ja");
Trashkid2000
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 561
Erhaltene Danke: 137



BeitragVerfasst: Di 01.03.11 17:09 
Oder einfach mit dem is-Operator:
ausblenden C#-Quelltext
1:
2:
3:
object testObject = "bla";
if(testObject is string)
  Console.WriteLine("Ja");
Aber eine ArrayList als untypisiertes etwas ist sowieso nicht optimal...
LG, Marko