Пример #1
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);
        }
        private static Base MethodName3()
        {
            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 void IfStatement2()
        {
            Base     x = null;
            Derived  y = null;
            Derived2 z = null;

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

            if (x == null)
            {
                x = z;
            }
        }
Пример #5
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;
            }
        }
        public static void MethodName()
        {
            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);
            }
        }
        private static Base MethodName2()
        {
            Derived  x = null;
            Derived2 y = null;

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

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

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

            if (x == null)
            {
                return(y);
            }
            else
            {
                return(x);
            }
        }
        private static IEnumerable MethodName5()
        {
            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);
            }
        }