C#NET2008 What's the meaning of operator ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lenniekuah
    New Member
    • Oct 2006
    • 126

    #1

    C#NET2008 What's the meaning of operator ?

    Hullo Good Guys,
    I need your help, Please help me.

    I noticed the use of this operator ?
    What's the meaning of it.

    This is the coding that contained ?
    Code:
    txtCustomer.text = DR["CompanyName"] == System.DBNull.Value ? string.Empty : Convert.ToString(DR["CompanyName"]);
    
    txtAddress.text =  DR["Address"] == System.DBNull.Value? string.Empty: Convert.ToString(DR["Address"]);

    Thank you for your help.
  • Joseph Martell
    Recognized Expert New Member
    • Jan 2010
    • 198

    #2
    The "?" is actually 1 part of the ?: ternary operator. Look at this documentation from MSDN for more information.

    Unlike most of the other operators, this one is a little difficult to look up if your not familiar with it.

    Comment

    • lenniekuah
      New Member
      • Oct 2006
      • 126

      #3
      Hi Joseph Martell,
      Thank you for the URL Link and also for sharing the informatio with me. I will check it out and try it out of my coding.

      Thank you.

      Comment

      • Subin Ninan
        New Member
        • Sep 2010
        • 91

        #4
        Code:
        int i = (1 < 2) ? 1 : 2;
        this is an inline assignment operator on basis of if condition. Value of variable i after execution will be 1.

        Value = (condition)?<th en part>:<else part>;

        Comment

        • lenniekuah
          New Member
          • Oct 2006
          • 126

          #5
          Hi Subin Ninan,
          Thank you very much for sharing the information with me.
          It has help me logically.

          Comment

          Working...