SoFunction
Updated on 2025-03-01

c# operator?? null coalescing operator

c# operator?? null coalescing operator

Updated: June 13, 2009 20:30:33 Author:
?? "null coalescing" operator is a new operator provided by C#. The function provided by this operator is to determine whether the operand on the left is null. If so, the result is the operand on the right; if so, the operation is returned. If not null, the operand on the left is returned.
We can look at the following examples to see how this operator is used:
Copy the codeThe code is as follows:

string message = "Hello World";
string result = message ?? "null";
//The content of the result here is Hello World

Let’s take a look at the following example:
Copy the codeThe code is as follows:

string message = null;
string result = message ?? "It's null";
//The content of result here will be It's null
  • c#
  • Operator
  • null

Related Articles

  • How to customize error pages and display error pages under MVC

    This article mainly introduces in detail the way to customize error pages and display error pages under MVC, which has certain reference value. Interested friends can refer to it.
    2017-11-11
  • Data binding GridView control

    This article mainly introduces the GridView control in data binding. The function of the GridView control is to display data in the data source on the web page. Friends who are interested in the GridView control can refer to it.
    2016-01-01
  • Add sample code in TextBox

    It is indeed a bit difficult for some novice friends to add to TextBox. Here are some specific implementation methods.
    2013-11-11
  • WeChat official account customer service interface

    This article mainly introduces the relevant information on the WeChat official account customer service interface in detail, which has certain reference value. Interested friends can refer to it.
    2016-11-11
  • aspx does not display an instance of ViewState

    Rewrite the Render method to remove ViewState and improve the performance of the website
    2013-03-03
  • In-depth analysis using Action and Func generic delegation in .NET

    Delegates occupy an extremely important position in C# programming. Delegates can encapsulate functions into delegates, and multiple delegates can be merged into one delegate. Delegates can be stored and passed like ordinary objects and then called at any time. Therefore, the implementation of function callback mechanism in C# basically depends on delegates. Interested friends can refer to the following
    2012-12-12
  • Get the last character of the string array

    Get the last character
    2008-05-05
  • VS2012/VS2013 Local Publishing Website Issues Collection (HTTP Error Code)

    This article mainly introduces in detail to you the problem of VS2012/VS2013 local publishing website. The solution to HTTP error codes is of certain reference value. Interested friends can refer to it.
    2017-04-04
  • TreeView recursive loop child nodes to generate tree menu instance

    This article mainly introduces the method of TreeView recursive loop child nodes to generate tree menus, involving recursive algorithms and node operation related techniques. Friends who need it can refer to it
    2016-07-07
  • c# connection string database server port number .net status server port number

    Normal database connection string configuration, which is when the MSSQL server port is 1433 (default).
    2009-06-06

Latest Comments