Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialNader Alharbi
2,253 PointsC# Windows Application to Modify Existing Class File Based on User Selections.
Good Afternoon,
I have no idea if this type of questions is allowed here because i have not read the rules.
I am trying to create windows application to modify .CS file that i have based on users selections in my GUI.
The .CS file contains multiple methods and my idea is to change these methods codes based on users selection and allow the user to choose any combination of limited methods and variables he/she wish.
Ex. The user will have the option to select between (IF or While) and decide a combination of limited numbers of (&& or ||). if (chosenmethod(chosenvar) && chosenmethod2(chosenvar2) || chosenmethod3(chosenvar3) <= chosen number) { selectedaction(chosenvar); }
This is an example of the code i need my application to generate for the user.
Sorry for the long post, what i want to ask is it possible to perform this? and if there any references i should be looking at while creating this application.
This is my first project, thus i am having difficulties getting started.
2 Answers
Steven Parker
231,198 PointsIt is possible to do this, but for the results to be effective, the program would need to be recompiled.
Another approach you might consider is to store the user's choices in a database, and then use the database values to control the evaulations being performed as the program runs. That would make the entire thing interactive without being rebuilt.
Nader Alharbi
2,253 PointsSteven Parker Thank you for your reply.
I did not quite understand the recompile part, i have set goals for myself as a novice coder.
Maybe i confused things up a bit. To clear things up, my application should generate an external text file organized in a certain way depending on users combination of choices.
You can say it is a code generator for people who do not know how code based on a nice easy GUI.
Best regards,
Steven Parker
231,198 PointsI thought you wanted the program to modify itself, but now your objective makes more sense. And sure, you can do this once you have a complete understanding of the language. The concepts of displaying and reading user inputs and writing to files and logic processing are all things you should find covered in the courses.
Something the courses here won't cover but you might enjoy is this article on the brand-new feature in the latest version of C# called source generation.