what does this line exactly do

what does the ? do in this case.

 
  string menu=DailySchedule[i].emergency==1?"true":"false";
how would i rewrite this as an if else
string menu= DailySchedule[i].emergency==1?"true":"false";
Last edited on
I believe it would be:

1
2
3
4
5
6
	if (DailySchedule[i].emergency == 1) {
		string menu = "true";
	}
	else {
		string menu = "false";
	}


But would be better written

1
2
3
4
5
6
7
        string menu;
	if (DailySchedule[i].emergency == 1) {
		menu = "true";
	}
	else {
		menu = "false";
	}
Last edited on
Topic archived. No new replies allowed.