var codeProvider = new CSharpCodeProvider();
or
var co开发者_StackOverflowdeProvider = new CodeDomProvider.CreateProvider("C#");
They appear to do the same thing which is confusing me!
var codeProvider = new CSharpCodeProvider();
where CSharp
is the known language prior to runtime.
See note below on CodeDomProvider.CreateProvider Method reference:
This method is most commonly used to create an instance of a code provider in an application that may optionally use one of several providers. CreateProvider allows you to specify at run time the code provider you wish to instantiate. If you know at design time which code provider is to be used, you should create an instance of that code provider rather than use the CreateProvider method.
I think both CSharpCodeProvider and CodeDomProvider.CreatProvider are pointing to the same object instantiation, so it doesn't matter which one you use.
精彩评论