Click here to Skip to main content
14,361,750 members
   

C#

 
GeneralRe: call enum as argument in Method? Pin
BillWoodruff7-Sep-19 20:04
mveBillWoodruff7-Sep-19 20:04 
GeneralRe: call enum as argument in Method? Pin
Member 145823347-Sep-19 17:32
memberMember 145823347-Sep-19 17:32 
GeneralRe: call enum as argument in Method? Pin
BillWoodruff7-Sep-19 20:02
mveBillWoodruff7-Sep-19 20:02 
AnswerRe: call enum as argument in Method? Pin
BillWoodruff7-Sep-19 16:29
mveBillWoodruff7-Sep-19 16:29 
AnswerRe: call enum as argument in Method? Pin
BillWoodruff7-Sep-19 20:01
mveBillWoodruff7-Sep-19 20:01 
AnswerRe: call enum as argument in Method? Pin
OriginalGriff7-Sep-19 21:03
protectorOriginalGriff7-Sep-19 21:03 
AnswerRe: call enum as argument in Method? Pin
Gerry Schmitz8-Sep-19 9:09
mveGerry Schmitz8-Sep-19 9:09 
AnswerRe: call enum as argument in Method? Pin
Sharp Ninja9-Sep-19 5:56
memberSharp Ninja9-Sep-19 5:56 
In your UI, you have an event handler for the dropdown list, so we'll start from that perspective.
public void DropDownSelectChanged(object sender, EventArgs args)
{
  // assuming the sender is the drop down
  var ddl = sender as DropDown; // whatever the actual control is in your GUI
  Calculate(ddl.SelectedItem);
}

The Calculate method will then call the appropriate Action to react to the state of the application.
// These get set in your constructor.
public Action MoreApplesAction {get; set;}
public Action FewerApplesAction {get; set;}

public void Caclulate(Fruit selectedFruit)
{
  // Of course, these should be properties somewhere
  var Apple = 5
  var Orange = 1

  // It's OK to create guards like this to
  // enhance readability, but don't be surprised
  // when someone objects because of the memory
  // allocation.
  var MoreApples = Apple > Orange;
  var FewerApples = Apple < Orange;

  switch(selectedFruit)
  {
    case Apple:
      if(MoreApplies) MoreApplesAction?.Invoke();
      break;

    case Orange:
      if(FewerApples) FewerApplesAction?.Invoke();
      break;
  }
}
The Sharp Ninja

QuestionVlookup a Value on a CSV file C# Pin
Member 1457406731-Aug-19 10:52
memberMember 1457406731-Aug-19 10:52 
AnswerRe: Vlookup a Value on a CSV file C# Pin
OriginalGriff31-Aug-19 20:55
protectorOriginalGriff31-Aug-19 20:55 
AnswerRe: Vlookup a Value on a CSV file C# Pin
BillWoodruff1-Sep-19 13:00
mveBillWoodruff1-Sep-19 13:00 
Questionreading text file as an array by using streamreader Pin
Member 1457152028-Aug-19 20:37
memberMember 1457152028-Aug-19 20:37 
AnswerRe: reading text file as an array by using streamreader Pin
OriginalGriff28-Aug-19 20:56
protectorOriginalGriff28-Aug-19 20:56 
AnswerRe: reading text file as an array by using streamreader Pin
Richard MacCutchan28-Aug-19 22:27
protectorRichard MacCutchan28-Aug-19 22:27 
QuestionRe: reading text file as an array by using streamreader Pin
Maciej Los28-Aug-19 22:42
protectorMaciej Los28-Aug-19 22:42 
AnswerRe: reading text file as an array by using streamreader Pin
Maciej Los28-Aug-19 23:32
protectorMaciej Los28-Aug-19 23:32 
AnswerRe: reading text file as an array by using streamreader Pin
BillWoodruff29-Aug-19 0:04
mveBillWoodruff29-Aug-19 0:04 
AnswerRe: reading text file as an array by using streamreader Pin
Gene M10-Sep-19 15:48
memberGene M10-Sep-19 15:48 
AnswerRe: reading text file as an array by using streamreader Pin
Jacek Gajek12-Sep-19 10:35
memberJacek Gajek12-Sep-19 10:35 
QuestionTool to add code in my existing class Pin
Bastien Vandamme28-Aug-19 6:48
memberBastien Vandamme28-Aug-19 6:48 
AnswerRe: Tool to add code in my existing class Pin
Richard MacCutchan28-Aug-19 6:54
protectorRichard MacCutchan28-Aug-19 6:54 
AnswerRe: Tool to add code in my existing class Pin
Richard Deeming28-Aug-19 8:47
mveRichard Deeming28-Aug-19 8:47 
AnswerRe: Tool to add code in my existing class Pin
BillWoodruff28-Aug-19 19:35
mveBillWoodruff28-Aug-19 19:35 
QuestionValidating textbox value against an excel worksheet and append to datagridview Pin
Member 1457117728-Aug-19 5:51
memberMember 1457117728-Aug-19 5:51 
AnswerRe: Validating textbox value against an excel worksheet and append to datagridview Pin
ZurdoDev28-Aug-19 6:20
professionalZurdoDev28-Aug-19 6:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.