使用c#中的codedom在codemember方法中实例化一个类 [英] instantiate a class inside a codemembermethod using codedom in c#
本文介绍了使用c#中的codedom在codemember方法中实例化一个类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在方法或codemember方法中生成以下代码?如何使用codedom生成它?
SqlConnection con1 = new SqlConnection(Core.ConnectionStringSample);
How can i generate the below code inside a method or codemembermethod? How can i generate it using codedom?
SqlConnection con1 = new SqlConnection(Core.ConnectionStringSample);
推荐答案
很容易发出代码,但我想在生成它们时正确识别哪个方法,类型引用等。
我尝试使用Codevariabledeclarationstatement但输出就像一个字符串或与console.writeline的输出相同。
没有生成某种类型的正确标识。
it is easy to emit the code but i want to properly identify which is the method, type reference etc. when they are generated.
I tried using Codevariabledeclarationstatement but the output is just like a string or same as the output of console.writeline.
The proper identification for a certain type does not generated.
SqlConnection cn = new SqlConnection();
这篇关于使用c#中的codedom在codemember方法中实例化一个类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文