public class MyInfoObject
{
public int MyNumberOfThingiesDone;
public string MyReallyCoolInfo;
}
thenpublic interface ICommand
{
MyInfoClass Execute();
}
Something like:public class FlipDownCommand : ICommand
{
private Light _light;
public FlipDownCommand(Light light)
{
_light = light;
}
public MyInfoClass Execute()
{
MyInfoClass infoClass = new MyInfoClass();
infoClass.MyNumberOfThingiesDone = 101;
infoClass.MyReallyCoolInfo = string.Empty;
_light.TurnOff();
return infoClass;
}
}
public class FlipUpCommand : ICommand
{
private Light _light;
public FlipUpCommand(Light light)
{
_light = light;
}
public MyInfoClass Execute()
{
MyInfoClass infoClass = new MyInfoClass();
infoClass.MyNumberOfThingiesDone = int.MinValue;
infoClass.MyReallyCoolInfo = "Kittens are cute."
_light.TurnOn();
return infoClass;
}
}
public class Switch
{
private List<ICommand> _commands = new List<ICommand>();
public MyInfoClass StoreAndExecute(ICommand command)
{
_commands.Add(command);
return command.Execute();
}
}
then in use: if (cmd == "ON")
{
string infoINeed = s.StoreAndExecute(switchUp);
}
else if (cmd == "OFF")
{
int InfoNumbers = s.StoreAndExecute(switchDown);
}
else
{
Console.WriteLine("Command \"ON\" or \"OFF\" is required.");
}
If you showed your code and what you were trying to do it would be helpful.