Click here to Skip to main content
14,836,972 members
Home / Discussions / C#
   

C#

 
GeneralRe: call enum as argument in Method? Pin
BillWoodruff7-Sep-19 19:04
mveBillWoodruff7-Sep-19 19:04 
GeneralRe: call enum as argument in Method? Pin
Member 145823347-Sep-19 16:32
MemberMember 145823347-Sep-19 16:32 
GeneralRe: call enum as argument in Method? Pin
BillWoodruff7-Sep-19 19:02
mveBillWoodruff7-Sep-19 19:02 
AnswerRe: call enum as argument in Method? Pin
BillWoodruff7-Sep-19 15:29
mveBillWoodruff7-Sep-19 15:29 
AnswerRe: call enum as argument in Method? Pin
BillWoodruff7-Sep-19 19:01
mveBillWoodruff7-Sep-19 19:01 
AnswerRe: call enum as argument in Method? Pin
OriginalGriff7-Sep-19 20:03
mveOriginalGriff7-Sep-19 20:03 
AnswerRe: call enum as argument in Method? Pin
Gerry Schmitz8-Sep-19 8:09
mveGerry Schmitz8-Sep-19 8:09 
AnswerRe: call enum as argument in Method? Pin
Sharp Ninja9-Sep-19 4:56
MemberSharp Ninja9-Sep-19 4: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 9:52
MemberMember 1457406731-Aug-19 9:52 
AnswerRe: Vlookup a Value on a CSV file C# Pin
OriginalGriff31-Aug-19 19:55
mveOriginalGriff31-Aug-19 19:55 
AnswerRe: Vlookup a Value on a CSV file C# Pin
BillWoodruff1-Sep-19 12:00
mveBillWoodruff1-Sep-19 12:00 
Questionreading text file as an array by using streamreader Pin
Member 1457152028-Aug-19 19:37
MemberMember 1457152028-Aug-19 19:37 
AnswerRe: reading text file as an array by using streamreader Pin
OriginalGriff28-Aug-19 19:56
mveOriginalGriff28-Aug-19 19:56 
AnswerRe: reading text file as an array by using streamreader Pin
Richard MacCutchan28-Aug-19 21:27
mveRichard MacCutchan28-Aug-19 21:27 
QuestionRe: reading text file as an array by using streamreader Pin
Maciej Los28-Aug-19 21:42
mveMaciej Los28-Aug-19 21:42 
AnswerRe: reading text file as an array by using streamreader Pin
Maciej Los28-Aug-19 22:32
mveMaciej Los28-Aug-19 22:32 
AnswerRe: reading text file as an array by using streamreader Pin
BillWoodruff28-Aug-19 23:04
mveBillWoodruff28-Aug-19 23:04 
AnswerRe: reading text file as an array by using streamreader Pin
Gene M10-Sep-19 14:48
MemberGene M10-Sep-19 14:48 
AnswerRe: reading text file as an array by using streamreader Pin
Lutosław12-Sep-19 9:35
MemberLutosław12-Sep-19 9:35 
QuestionTool to add code in my existing class Pin
Bastien Vandamme28-Aug-19 5:48
MemberBastien Vandamme28-Aug-19 5:48 
AnswerRe: Tool to add code in my existing class Pin
Richard MacCutchan28-Aug-19 5:54
mveRichard MacCutchan28-Aug-19 5:54 
AnswerRe: Tool to add code in my existing class Pin
Richard Deeming28-Aug-19 7:47
mveRichard Deeming28-Aug-19 7:47 
AnswerRe: Tool to add code in my existing class Pin
BillWoodruff28-Aug-19 18:35
mveBillWoodruff28-Aug-19 18:35 
QuestionValidating textbox value against an excel worksheet and append to datagridview Pin
Member 1457117728-Aug-19 4:51
MemberMember 1457117728-Aug-19 4:51 
AnswerRe: Validating textbox value against an excel worksheet and append to datagridview Pin
ZurdoDev28-Aug-19 5:20
professionalZurdoDev28-Aug-19 5: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.