You're looking for the CSharpCodeProvider class.
For example:
var compiler = new CSharpCodeProvider(new Dictionary { { "CompilerVersion", "v4.0" } });
var options = new CompilerParameters { OutputAssembly = path);
var results = compiler.CompileAssemblyFromFile(options, sourceFile);