开发者

Correct way to get an instance of CodeDomProvider

开发者 https://www.devze.com 2023-02-25 04:27 出处:网络
var codeProvider = new CSharpCodeProvider(); or var co开发者_StackOverflowdeProvider = new CodeDomProvider.CreateProvider(\"C#\");
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

精彩评论

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