Пример #1
0
        private static Base IfReturnToReturn(Derived x, Derived2 y)
        {
            if (x != null)
            {
                return(x);
            }

            return(y);

            if (x != null)
            {
                return(x);
            }

            return(y);

            if (x == null)
            {
                return(y);
            }

            return(x);

            if (x == null)
            {
                return(y);
            }

            return(x);
        }
Пример #2
0
        private static Base IfReturnToReturn()
        {
            Derived  x = null;
            Derived2 y = null;

            if (x != null)
            {
                return(x);
            }

            return(y);

            if (x != null)
            {
                return(x);
            }

            return(y);

            if (x == null)
            {
                return(y);
            }

            return(x);

            if (x == null)
            {
                return(y);
            }

            return(x);
        }
Пример #3
0
        private static Base IfElseToReturn()
        {
            Derived  x = null;
            Derived2 y = null;

            if (x != null)
            {
                return(x);
            }
            else
            {
                return(y);
            }

            if (null != x)
            {
                return(x);
            }
            else
            {
                return(y);
            }

            if (x != null)
            {
                return(x);
            }
            else
            {
                return(y);
            }

            if (x == null)
            {
                return(y);
            }
            else
            {
                return(x);
            }

            if (null == x)
            {
                return(y);
            }
            else
            {
                return(x);
            }

            if (x == null)
            {
                return(y);
            }
            else
            {
                return(x);
            }
        }
Пример #4
0
        private static Base IfElseToReturn(Derived x, Derived2 y)
        {
            if (x != null)
            {
                return(x);
            }
            else
            {
                return(y);
            }

            if (null != x)
            {
                return(x);
            }
            else
            {
                return(y);
            }

            if (x != null)
            {
                return(x);
            }
            else
            {
                return(y);
            }

            if (x == null)
            {
                return(y);
            }
            else
            {
                return(x);
            }

            if (null == x)
            {
                return(y);
            }
            else
            {
                return(x);
            }

            if (x == null)
            {
                return(y);
            }
            else
            {
                return(x);
            }
        }
Пример #5
0
        private static void IfStatement2()
        {
            Base     x = null;
            Derived  y = null;
            Derived2 z = null;

            // a
            if (x == null)
            {
                // b
                x = y;
            }

            if (x == null)
            {
                x = z;
            }
        }
Пример #6
0
        public static void IfElseToAssignment()
        {
            Derived  x = null;
            Derived2 y = null;
            Base     z = null;

            if (x != null)
            {
                z = x;
            }
            else
            {
                z = y;
            }

            if (x != null)
            {
                z = x;
            }
            else
            {
                z = y;
            }

            if (x == null)
            {
                z = y;
            }
            else
            {
                z = x;
            }

            if (x == null)
            {
                z = y;
            }
            else
            {
                z = x;
            }
        }
Пример #7
0
        private static IEnumerable IfElseToYieldReturn2()
        {
            Derived  x = null;
            Derived2 y = null;

            if (x != null)
            {
                yield return(x);
            }
            else
            {
                yield return(y);
            }

            if (x != null)
            {
                yield return(x);
            }
            else
            {
                yield return(y);
            }

            if (x == null)
            {
                yield return(y);
            }
            else
            {
                yield return(x);
            }

            if (x == null)
            {
                yield return(y);
            }
            else
            {
                yield return(x);
            }
        }
Пример #8
0
            private static void IfStatement2()
            {
                Derived  y = null;
                Derived2 z = null;

                Base x = GetValueOrDefault2();

                // a
                if (x == null)
                {
                    // b
                    x = y;
                }

                Base x2 = GetValueOrDefault2();

                if (x2 == null)
                {
                    x2 = z;
                }
            }
Пример #9
0
        private static IEnumerable IfElseToYieldReturn2(Derived x, Derived2 y)
        {
            if (x != null)
            {
                yield return(x);
            }
            else
            {
                yield return(y);
            }

            if (x != null)
            {
                yield return(x);
            }
            else
            {
                yield return(y);
            }

            if (x == null)
            {
                yield return(y);
            }
            else
            {
                yield return(x);
            }

            if (x == null)
            {
                yield return(y);
            }
            else
            {
                yield return(x);
            }
        }
Пример #10
0
        private static void IfElseToAssignment(Derived x, Derived2 y, Base z)
        {
            if (x != null)
            {
                z = x;
            }
            else
            {
                z = y;
            }

            if (x != null)
            {
                z = x;
            }
            else
            {
                z = y;
            }

            if (x == null)
            {
                z = y;
            }
            else
            {
                z = x;
            }

            if (x == null)
            {
                z = y;
            }
            else
            {
                z = x;
            }
        }