zoukankan      html  css  js  c++  java
  • if (user?.Identity?.IsAuthenticated ?? false)这几个问号分别都代表啥意思?

    if (user?.Identity?.IsAuthenticated ?? false)这几个问号分别都代表啥意思?

    0
    悬赏园豆:5 [已解决问题] 浏览: 229次 解决于 2018-05-16 13:27
    复制代码
                var user = HttpContext.User;
                if (user?.Identity?.IsAuthenticated ?? false)
                {
    
                }
                else
                {
    
                }
    复制代码

    如题,求解。

    屌丝大叔的笔记的主页 屌丝大叔的笔记 | 初学一级 | 园豆:67
    提问于:2018-05-16 10:26

    牛逼的写法,谢谢dudu,xiexie演员。

    屌丝大叔的笔记 1年前   回复
    最佳答案
    1

    ? 如果不为null,执行其后的方法;?? 如果为null,返回其后的值。

            <div id="answer_option_226950">
                <div class="qclear">
                        <div class="lf green">
                            收获园豆:<span class="red">5</span>
                        </div>
                    <div class="answer_author">
                                <a class="bluelink linkanswercommenttiny" aid="226950" id="link_answercomment_226950" onclick="showCommentMarkdownEditor('link_answercomment_226950', 0)" href="javascript:void(0);">回复</a>
                            <span class="v-split">|</span>
                        <a href="/u/dudu/" class="bluelink">dudu</a>
                        <span class="v-split">|</span>
                        <a class="graylink" href="/q/faq#qt">高人七级</a>
                        <span class="v-split">|</span>园豆:41494
                        <span class="v-split">|</span>
                        2018-05-16 10:32
                    </div>
                </div>
            </div>
            <div class="q_answercomm" id="q_answercomm_226950">
            </div>
    
    其他回答(1)
    0

    等价于

             bool isNull;
                if (user != null)
                {
                    if (user.Identity != null)
                    {
                        if (user.Identity.IsAuthenticated != null)
                        {
                            isNull = user.Identity.IsAuthenticated;
                        }
                    }
                }
                isNull = false;
                if (isNull)
                {
    
            } </span></pre>
    
                        <div id="answer_option_226955">
    
    回复 | 写代码的相声演员 | 园豆:541 (小虾三级) | 2018-05-16 11:38
    </div>
    
                        </div>
    
                        <div class="q_answercomm qclear" id="q_answercomm_226955">
                        </div>
    
    清除回答草稿
    上传图片

    Ctrl+Enter键快速提交
    <div id="google_ad_bottom">
        <script type="text/javascript">
            var googletag = googletag || {};
            googletag.cmd = googletag.cmd || [];
            (function () {
                var gads = document.createElement('script');
                gads.async = true;
                gads.type = 'text/javascript';
                var useSSL = 'https:' == document.location.protocol;
                gads.src = (useSSL ? 'https:' : 'http:') +
                    '//www.googletagservices.com/tag/js/gpt.js';
                var node = document.getElementsByTagName('script')[0];
                node.parentNode.insertBefore(gads, node);
            })();
        </script>
    
        <script type="text/javascript">
            googletag.cmd.push(function () {
                googletag.defineSlot('/1090369/cnblogs_question_Q2', [728, 90], 'div-gpt-ad-1436511848662-0').addService(googletag.pubads());
                googletag.pubads().enableSingleRequest();
                googletag.pubads().collapseEmptyDivs();
                googletag.enableServices();
            });
        </script>
    
        <!-- /1090369/cnblogs_question_Q2 -->
        <div id="div-gpt-ad-1436511848662-0" style="height:90px; 728px;" data-google-query-id="CPeVmvWlrOMCFQcaKgodbM8C7w">
            
        <div id="google_ads_iframe_/1090369/cnblogs_question_Q2_0__container__" style="border: 0pt none;"><iframe id="google_ads_iframe_/1090369/cnblogs_question_Q2_0" title="3rd party ad content" name="google_ads_iframe_/1090369/cnblogs_question_Q2_0" width="728" height="90" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" srcdoc="" style="border: 0px; vertical-align: bottom;" data-google-container-id="1" data-load-complete="true"></iframe></div></div>
    </div>
    
                </div>
  • 相关阅读:
    redis存储session配制方法
    thanks使用注意事项;
    mongodb sort limit和skip用法
    mongoose的用法(注:连接数据库)
    mongoose查询特定时间段文档的方法
    webworker的使用案例
    js 传参数
    redis.config翻译
    Oracle keep详解
    自学之笔记总结
  • 原文地址:https://www.cnblogs.com/owenzh/p/11170077.html
Copyright © 2011-2022 走看看