The best resources for developers

I am doing some project with CSharpCodeProvider Compilation Performance. The code provided is compilable from scratch. How should I modify my code?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.CSharp;
using System.CodeDom;
using System.IO;
using System.CodeDom.Compiler;
using System.Reflection;

namespace CodeDomQuestion
    class Program

        private static void Main(string[] args)
            Program p = new Program();

        public void dotest(string outputname)
            CSharpCodeProvider cscProvider = new CSharpCodeProvider();
            CompilerParameters cp = new CompilerParameters();
            cp.MainClass = null;
            cp.GenerateExecutable = true;
            cp.OutputAssembly = outputname;
            CodeNamespace ns = new CodeNamespace("StackOverflowd");

            CodeTypeDeclaration type = new CodeTypeDeclaration();
            type.IsClass = true;
            type.Name = "MainClass";
            type.TypeAttributes = TypeAttributes.Public;

            CodeMemberMethod cmm = new CodeMemberMethod();
            cmm.Attributes = MemberAttributes.Static;
            cmm.Name = "Main";
            cmm.Statements.Add(new CodeSnippetExpression("System.Console.WriteLine("f"zxcvv)"));

            CodeCompileUnit ccu = new CodeCompileUnit();

            CompilerResults results = cscProvider.CompileAssemblyFromDom(cp, ccu);

            foreach (CompilerError err in results.Errors)
                Console.WriteLine(err.ErrorText + " - " + err.FileName + ":" + err.Line);


Tags: c# compiler-construction performance

Source: By Andrew Peters as answer to the question

This code snippet was collected from stackoverflow, and is licensed under CC BY-SA 2.5

Related code-snippets: