Click here to Skip to main content
15,886,100 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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);
Posted
Comments
Sergey Alexandrovich Kryukov 27-Dec-12 12:20pm    
1) I wonder why?

2) Why don't you want simply to write a text of code (compose or modify it during run-time, if you really need to use CodeDOM) and compile with CodeDOM into an assembly? This is a major way to use CodeDOM...

3) If the above cannot suit your (then, why?), did you consider using System.Reflection.Emit, to just emit the code you need?

You really need to answer, otherwise it would not make sense to continue.

Thank you,
—SA

1 solution

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.
C#
SqlConnection cn = new SqlConnection();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900