Convert string contents into line of code?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • BH

    Convert string contents into line of code?

    Hi all

    does C# have some way to turn a string's contents ( from a db or whatever )
    into an executable line of code?

    int myValue = 0;
    string lineOfCode = "myValue = 20;"
    //somehow 'execute' the statement in the string....
    lineOfCode.Exec uteMe(); //?? is this sort of thing possible ??
    //myValue is now equal to 20

    Thanks...


  • Pieter Philippaerts

    #2
    Re: Convert string contents into line of code?

    "BH" <bohiggy@yahoo. com> wrote in message[color=blue]
    > does C# have some way to turn a string's contents ( from a db or[/color]
    whatever )[color=blue]
    > into an executable line of code?[/color]

    Yes, through the use of reflection. Look here for an example:


    Regards,
    Pieter Philippaerts
    Managed SSL/TLS: http://www.mentalis.org/go.php?sl


    Comment

    • Pieter Philippaerts

      #3
      Re: Convert string contents into line of code?

      "BH" <bohiggy@yahoo. com> wrote in message[color=blue]
      > does C# have some way to turn a string's contents ( from a db or[/color]
      whatever )[color=blue]
      > into an executable line of code?[/color]

      Yes, through the use of reflection. Look here for an example:


      Regards,
      Pieter Philippaerts
      Managed SSL/TLS: http://www.mentalis.org/go.php?sl


      Comment

      Working...