Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

C# : building objects based on string

Name: Anonymous 2013-10-22 1:47

Is there any way of creating (multiple) instances of a subclass (or any other standard object) based on a string that has been read in from a class. Currently I have found this can be done with a switch, or with reflection, but I am not allowed to use reflection.

I've tried finding a solution to this issue that doesn't involve a switch (its quite ugly with the switch) but all I've found is people suggesting to use reflection, which I cannot for this particular program.

Name: Anonymous 2013-10-22 1:51

String that has been read in from a file*.

Name: Anonymous 2013-10-22 1:58

Yes.
start.FileName = "c:\\python2\\python.exe";
start.Arguments = "-c print(\\\"HALLO WERLD\\\")";
start.UseShellExecute = false;
start.RedirectStandardOutput = true;
Process process = Process.Start(start);

Replace the filename to your python path and the python code to whatever it is you want it to do. Couldn't be simpler.

Don't change these.
Name: Email:
Entire Thread Thread List