C# 获得对象的命名空间 ?.

            A a = new A();
            var t = a?.ToString();

            //t = WebApplication1.Controllers.A  //获得命名空间和类名

 

   var t1 = (A)null;
   var t = t1?.ToString(); 
// //t = null;

 

pdfViewer1.Document.Dispose();
pdfViewer1.Document ?.Dispose(); //非托管资源

?. 是什么意思

NULL检查运算符(?.)  

转自  https://www.cnblogs.com/youmingkuang/p/11459615.html

            /*
             object a = null;
            a.ToString();
            System.NullReferenceException:“未将对象引用设置到对象的实例。”
        */
            object a = null;
           var t = a ?. ToString(); //返回null

 

 

posted @ 2019-09-06 08:38  enych  阅读(626)  评论(0编辑  收藏  举报