as you can see in my code, I want to hold( set ) a method into an object. And call the method with that object...
Please take look at the code, you can understand easly; it's hard to explain in plain English...
My question is; Ofcourse "Action operation" object can't hold the method that will be called.
So, how can I solve this problem? What can I do?
...
enum CampaignUserChoice
{
Insert,
Update,
Delete,
Disable
}
private void AskUserAboutCampaignOperation(CampaignUserChoice choice)
{
string questionForUser = string.Empty;
string questionTitleForUser = string.Empty;
Action operation; //<<<<--------------------- this line, it's method holder
if (choice == CampaignUserChoice.Insert)
{
questionForUser = "Do you want to create a new campaign?";
questionTitleForUser = "NEW CAMPAIGN";
operation = InsertCampaign(TakeDatasFromGui()); //<---------- set which method you want to call
}
else
{
operation = UpdateCampaign( campaignId, TakeDatasFromGui());
}
//TODO write other elses...
switch (MessageBox.Show(questionForUser, questionTitleForUser, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question))
{
case DialogResult.Yes:
operation; //<<<------------------ call method here...
break;
case DialogResult.No:
// "No" processing
break;
case DialogResult.Cancel:
// "Cancel" processing
break;
}
}
Thank you very much for all answers...
You're trying to use delegates: