Instead of running a code in a Initialize() method for example, i want to just write a line, something like somecode.run() and it will run everything for me, allowing me to write all the code in a different location for the sake of organization.
I want the code to act like it was in that spot though, so i have access to privates etc.
whats the best way to do this?
edit to clarify:
Here is an example
public class game
{
public void Initialize()
{
I want to run some code here but I don't want to write it here,
I want to write it in another file for the sake of organization,
and just reference it somehow here, but yet still be able to use the
privates as if it was in this spot
}
}
Partial classes and methods should be able to do what you’re talking about (MS Documentation http://msdn.microsoft.com/en-us/library/wa80x488.aspx).
I’m not sure why you’d need to do anything more complex than what’s defined in the MSDN document. You can use virtuals to allow for overrides and call the base function, to call the original implementation. There’s a proper way to use inheritance to allow a lot of “tweaking” at the proper levels, but the initial partial classes and methods should allow you to do the basic format.
You normally see examples of partials in code that’s pre-written (for instance in LINQ by the DataContext).