目的 ?在asp.net中 [英] purpose of ? in asp.net

查看:84
本文介绍了目的 ?在asp.net中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

foreach (ListEntry mySpread in myFeed.Entries)
          {
              DataRow myDR = myTable.NewRow();
              foreach (ListEntry.Custom listrow in mySpread.Elements)
              {
              DC = myTable.Columns[listrow.LocalName] ?? myTable.Columns.Add(listrow.LocalName);

                  myDR[DC] = listrow.Value;


              }
              myTable.Rows.Add(myDR);
          }



什么?是用来 ?又是什么目的?在这段代码中??


what ?? is used for ? and what is the purpose of ?? in this code??

推荐答案

??与ASP.NET无关,而是一个C#运算符。如果操作数不为null,则返回左侧操作数;否则它返回右手操作数。



可以找到更多信息此处 [ ^ ]
The ?? has got nothing to do with ASP.NET, rather it's a C# operator. It returns the left-hand operand if the operand is not null; otherwise it returns the right hand operand.

More information can be found here[^]


这更多是关于用C#编程而不是ASP.Net。

这称为空合并运算符 - http://msdn.microsoft.com/en-us/library/1t3y8s4s.aspx [ ^ ]。
This is more about programming in C# than ASP.Net.
This is called the null coalesce operator - http://msdn.microsoft.com/en-us/library/1t3y8s4s.aspx[^].


其中a非常方便的操作员,可以使用Nullable Integer类型甚至是参考类型。



参考



使用空合并的不同方法 [ ^ ]
Its a very handy operator when it comes to work with Nullable Integer types and even on Reference Types.

Refer

Different Ways to Use Null Coalesce[^]


这篇关于目的 ?在asp.net中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆