Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save eterekhin/936ca0dfc41314ce7168051e2dded701 to your computer and use it in GitHub Desktop.
Save eterekhin/936ca0dfc41314ce7168051e2dded701 to your computer and use it in GitHub Desktop.
   public class Root
    {
        public Nested1Root Nested1Root;
        public Nested1Root2 Nested1Root2;
    }

    public class Nested1Root
    {
        public Least Least;
    }

    public class Least
    {
    }

    public class Nested1Root2
    {
        public Least2 Least;
    }

    public class Least2
    {
    }

    public static class Creator
    {
        public static Root CreateRoot()
        {
            return new Root()
            {
                Nested1Root =
                {
                    Least = new Least()
                },
                
                Nested1Root2 =
                {
                    Least = new Least2()
                }
            };
        }
    }

Если явно не вызывать конструктор, и использовать инициализаторы, то получается вполне читаемая структура(только так получается NRE)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment