What do these question marks mean?

Asked

Viewed 163 times

6

What do the question marks on that get.

What do they mean int? and ?? in this line of code, I have already found examples that used ? and ?? but never so many in a single line and this gets a little messy.

 public int Something
 {
    get { return (this.parameters["Loading"] as int?) ?? 1; }
 }

2 answers

10


The question mark here int? means that its variable of the integer type accepts null values, while the ?? means that the return of (this.parameters["Loading"] as int?) be null, set the same with 1, is a condition if the return is null set the same with 1.

4

It means that if the value of

this.parameters["Loading"]

is null the return will be 1.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.