Jump to content

Can you create a class from a string's contents?

- - - - -

  • Please log in to reply
1 reply to this topic

#1
etesientoooo

etesientoooo

    Newbie

  • Members
  • Pip
  • 1 posts
OK, what I am trying to is this:

say I have this:
////////////////////////////////////
class foo()

{
string nice = "very nice";
string johny = "class chocolate(){ MessageBox.Show(nice); }";
}
///////////////////////////////////

Now I want the entire string contents (class chocolate(){ MessageBox.Show(nice); }) - to become a new code...like this:

////////////////////////////////////////////////////////////////////////
class foo()

{
string nice = "very nice";
string johny = "class chocolate(){ MessageBox.Show(nice); }";
}
class chocolate(){ MessageBox.Show(nice); }
/////////////////////////////////////////////////////////////////////////


How can I achieve this?

10x alot!

#2
CommittedC0der

CommittedC0der

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,565 posts
With a little Googling.
.net - c# create an instance of a class from a string - Stack Overflow
Activator.CreateInstance Method (System)

EDIT: Also, please encase your code within code tags, like so: [CODE*]code goes here[/CODE*] just remove the '*' symbol.

Hope this helps. ~ Committed. :)
A man can be defined by what he does when no one is looking.
Science is only an educated theory, which we cannot disprove.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users