I A möchte eine Variable vom Typ B enthält jedoch einen Wert zu diesem varaible auf Zuweisung ich überprüfen wollen, ob es eine Instanz einer bestimmten Unterklasse von B. istTypprüfung Probleme
public class A {
public System.Type acceptedType;
public B target;
public A(System.Type t1){
this.acceptedType = t1;
}
public bool connect(B b1){
if(b1 is this.acceptedType){
this.target = b1;
return true;
}
return false;
}
}
jedoch ich bekomme:
Unexpected Symbol 'this', erwartet 'Typ'
Is 'System.Type' die falsche Variablentyp oder bin ich das nur Missverständnis 'ist' Operator?
'if (b1 ist typeof (this.acceptedType))' – Mardoxx