ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 또또 지나가다 본 코드..!! C# 더블쿼션마크 DOUBLE QUESTION MARK
    Algorithm 2009. 9. 22. 10:21
    반응형

    return (numOne != null ? numOne : (numTwo != null ? numTwo : 10));

    삼항연산자를 두번 섰다

    !!!  이런 크래이티브한 일이 있다니~!! 



    그런데 여기서 더 더 크래이티브하것이~!! 있었다는데

    바로 더블쿼션마크(물음표2개)



    참고 블러거의 말을 붙여오자면

    But with the double question mark operator we can do this:



    return ((numOne ?? numTwo) ?? 10);


    As you can see, the double question mark operator returns the first value that is not null.

    C# 일년가까이 해오면서 더블 쿼션 마크는 처음봄니다?





    중수로 가는 길은 멀고도 험하구나~! 
    널에이블타입 처음알고 신기했는데 

    물음표2개 다른분들은 알고 계셨나요?





    참고 :

    나의 의문이 시작된 곳??

    더블쿼션마크 처음본곳: (오타인가??)

    public class Renderer : Control {
        private bool _renderingSource = false;
     
        public virtual string SourceID {
            get {
                return ((string)ViewState["SourceID"]) ?? String.Empty;
            }
            set {
                ViewState["SourceID"] = value;
            }
        }
     
        private Renderer FindSource() {
            Control nc = NamingContainer;
            Control c = null;
            while (nc != null && c == null) {
                c = nc.FindControl(SourceID);
                nc = nc.NamingContainer;
            }
            if (c == null) {
                throw new InvalidOperationException("Cannot find control with ID '" +
                    SourceID +
                    "'.");
            }
            Renderer source = c as Renderer;
            if (source == null) {
                throw new InvalidOperationException("Control with ID '" +
                    SourceID +
                    "'is not a Render control.");
            }
            return source;
        }
     
        protected override void Render(HtmlTextWriter writer) {
            if (_renderingSource) {
                base.Render(writer);
            }
            else if (!String.IsNullOrEmpty(SourceID)) {
                RenderSourceControl(writer);
            }
        }
     
        private void RenderControlAsSource(HtmlTextWriter writer) {
            _renderingSource = true;
            try {
                RenderControl(writer);
            }
            finally {
                _renderingSource = false;
            }
        }
     
        private void RenderSourceControl(HtmlTextWriter writer) {
            Renderer source = FindSource();
            source.RenderControlAsSource(writer);
        }
    }


    쿼션 = QUESTION

    참고 사이트 주소
    반응형

    'Algorithm' 카테고리의 다른 글

    지나가다 본 코드  (0) 2009.11.23
    지나가다 본 코드  (0) 2009.11.05
    또 지나가다 본 코드..  (3) 2009.09.02
    지나가다 본 코드2  (0) 2009.07.20
    어디서 지나가다 본 코드~! ㅋㅋ  (0) 2009.06.26
    [C} algorithm 메크로 관련 알고리즘  (0) 2009.04.29

    댓글

Designed by Tistory.