c# ?? operator
来源:互联网 发布:ps破解软件下载 编辑:程序博客网 时间:2024/06/05 22:01
?? Operator
The ?? operator is called the null-coalescing operator and is used to define a default value for a nullable value types as well as reference types. It returns the left-hand operand if it is not null; otherwise it returns the right operand.
class NullCoalesce{ static int? GetNullableInt() { return null; } static string GetStringValue() { return null; } static void Main() { // ?? operator example. int? x = null; // y = x, unless x is null, in which case y = -1. int y = x ?? -1; // Assign i to return value of method, unless // return value is null, in which case assign // default value of int to i. int i = GetNullableInt() ?? default(int); string s = GetStringValue(); // ?? also works with reference types. // Display contents of s, unless s is null, // in which case display "Unspecified". Console.WriteLine(s ?? "Unspecified"); }}
- c# ?? operator
- => Operator (C# Reference)
- C# Operator Overloading
- => Operator (C# Reference)
- C# operator关键字
- C#关键字operator
- C#关键字operator
- C# PPT Operator
- c#关键词operator
- C# operator关键字
- C# Snippet Tutorial - The ?? Operator
- C# Vector定义、operator 使用
- C#关键字operator的用法
- C# operator 关键字的用法
- C#学习笔记-operator关键字
- c#中operator的运用
- operator->*
- operator[]
- Java线程的高级应用
- goole+ VS facebook 竞争IT的第三代霸主
- 线程属性设置
- C# Call another constructor in one constructor
- php操作memcache的使用测试总结
- c# ?? operator
- GOOGLE+ VS FACEBOOK 真人版
- 無題
- Linux学习资源
- 新浪微博密码加密分析
- Delphi XE2 发布了
- Android系统匿名共享内存Ashmem(Anonymous Shared Memory)驱动程序源代码分析
- something about PCIe
- Forms验证简介