开发者

Correct way to get an instance of CodeDomProvider

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜