Does Anyone Know C#? What Is The Question Notation?

Discussion in 'Education & Personal Growth' started by SuiDhaaga, Jan 5, 2022.

  1. SuiDhaaga

    SuiDhaaga Platinum IL'ite

    Messages:
    2,090
    Likes Received:
    1,417
    Trophy Points:
    283
    Gender:
    Female
    I am tracing code to study for a certification.

    Insee something like

    string requestBody = new StreamReader(req.body).ReadToEnd()
    Dynamic data = JsonConvert.DeserializeObject(requestBody)

    if (data?.values == null) …..

    what is the “?” In data?.values

    What should I even Google???
     
    Loading...

  2. Gauri03

    Gauri03 Moderator Staff Member IL Hall of Fame

    Messages:
    6,076
    Likes Received:
    12,634
    Trophy Points:
    445
    Gender:
    Female
    It's the Null-Conditional Operator. It is a way of pre-emptively testing for whether the object (data in this case) is null before accessing its values. Question marks can be used in a bunch of different ways in C#. See here - What does a question mark mean in C# code?
     
    SuiDhaaga likes this.
  3. SuiDhaaga

    SuiDhaaga Platinum IL'ite

    Messages:
    2,090
    Likes Received:
    1,417
    Trophy Points:
    283
    Gender:
    Female

    U r da best!!!!!!!
     

Share This Page