I need to generate nested classes using CodeDom. But I could not find any option to add a class( CodeTypeDeclaration) to another class as member.

>But I could not find any option to add a class( CodeTypeDeclaration) to another class as member.

CodeNamespace ns = new CodeNamespace("com.me");
        ns.Imports.Add(new CodeNamespaceImport("System"));

        CodeTypeDeclaration class1 = new CodeTypeDeclaration("Student");
        CodeTypeDeclaration class2 = new CodeTypeDeclaration("Marks");
        
        class2.IsClass =true;
        class2.TypeAttributes = System.Reflection.TypeAttributes.NestedPublic;
        
        class1.Members.Add(class2);
        ns.Types.Add(class1 );
        CodeDomProvider pv = CodeDomProvider.CreateProvider("C#");
        ICodeGenerator g = pv.CreateGenerator();
        g.GenerateCodeFromNamespace(ns, Console.Out, new CodeGeneratorOptions());