troubleshooting Question

Convert String to executable code

Avatar of C_Sharp_Programmer
C_Sharp_Programmer asked on
.NET ProgrammingC#
4 Comments1 Solution4347 ViewsLast Modified:
Is it possible in any way to convert a string of text into executable code (think: SQL query strings that are then used as actual executable SQL queries)?  I know this seems a strange request, but I'm wondering if there is a way to have code generated at run-time.  And before you ask, no, I cannot use a switch statement on a string and execute code based on the contents of the string ;)

Please refer to the following pseudo code:

static void Main()
   string executableStatement = "MessageBox.Show(\"Hello World\");";

private void executeCode(string executableString)
   //convert executableString to actual .NET code
   //execute converted code
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros