אוקי, יש לי את המחלקה הבאה, עם התנאי (לא מקוצר) שעובד:
קוד:
private string n;
private int p;
public Sys(string name, int pass)
{
if (name != "") this.n = name;
this.p = pass > 999 ? this.p: 12345 ;
}
public string getUser() {return this.n;}
public int getPass() { return this.p; }
עכשיו התנאי פה עובד, אבל כשניסיתי עם if מקוצר, ככה:
קוד:
this.n = name != "" ? this.n: "No";
this.p = pass > 4 ? pass: 12345;
הוא פשוט לא מחזיר כלום, אם כי אני לא מקבל הודעת שגיאה.