in Technology by
What do two question marks together mean in C#?

1 Answer

0 votes
by

It's the null coalescing operator, and quite like the ternary (immediate-if) operator. 

FormsAuth = formsAuth ?? new FormsAuthenticationWrapper();

expands to:

FormsAuth = formsAuth != null ? formsAuth : new FormsAuthenticationWrapper();

which further expands to:

if(formsAuth != null)
    FormsAuth = formsAuth;
else
    FormsAuth = new FormsAuthenticationWrapper();

Related questions

0 votes
    What do you mean by value types and reference types in C#?...
asked Jul 27, 2021 in Technology by JackTerrance
0 votes
    Write a JAVA program to store the marks of any 5 subjects in different variables. Calculate total and average. ... ANY INPUT METHOD Select the correct answer from above options...
asked Dec 22, 2021 in Education by JackTerrance
0 votes
    What happens when two positively charged material is placed together?...
asked Dec 14, 2020 in Technology by JackTerrance
0 votes
    how to print two arrays together in Javascript?...
asked Dec 10, 2020 in Technology by JackTerrance
0 votes
    Two different dice are thrown together, find the probability that the sum of the numbers appeared is less than 5. Select the correct answer from above options...
asked Nov 25, 2021 in Education by JackTerrance
0 votes
    Three coins are tossed together. Find the probability of getting: (i) exactly two heads (ii) at most two heads ( ... tail (iv) no tails Select the correct answer from above options...
asked Nov 25, 2021 in Education by JackTerrance
0 votes
    Three coins are tossed together. Find the probability of getting: (i) exactly two heads (ii) at least two heads ... head and one tail Select the correct answer from above options...
asked Nov 22, 2021 in Education by JackTerrance
0 votes
    The letters of the word ‘CLIFTON’ are placed at random in a row. What is the chance that two vowels come together? Select the correct answer from above options...
asked Nov 22, 2021 in Education by JackTerrance
0 votes
0 votes
    A die has its six faces marked 0, 1, 1, 1, 6, 6. Two such dice are thrown together and the total score is ... of getting a total of 7? Select the correct answer from above options...
asked Nov 21, 2021 in Education by JackTerrance
0 votes
0 votes
    Two dice are rolled together. Write all the possible outcomes and find the probability of getting (i) a number greater ... of the die) Select the correct answer from above options...
asked Nov 18, 2021 in Education by JackTerrance
...