Dave -- Thank you VERY much for the explanation- I am such beginner, I am having trouble knowing what I yet don't know (which is mostly everything). 1) a user selectable list of things (enums - or some other way?) 2) var(s) initialized that calculate something 3) an IF that wants to evaluate whether some var && some other var are true), and if so, do something. as it is now, I have to hard code all possibilities for each if (of each selected enums) using the vars directly. What I'd like is a way to have the user selected choice populate the iF with the appropriate var - that would alleviate hard coding each and every possibility. Am I even phrasing the question properly? probably not -- And if not, can you point me to an area I should study as to be better informed about syntax and possibilities? If I am way off, many apologies... Thanks so much again for your help-
M
Member_14582334
@Member_14582334
Posts
-
call enum as argument in Method? -
call enum as argument in Method?Greetings all - first time poster here, so please forgive me if I've submitted this incorrectly A user selects from a list of enum. I want that enum to be the actual name of a var. Then I'd like to use (some kind of placeholder argument in a method), to call that selected enum and evaluate the method. Here is the relevant example section:
{
public enum Fruit
{
Apple, Orange
}\[Parameter("Fruit Type")\] public Fruit FruitType { get; set; } public override void Calculate { var Apple = 5 var Orange = 1 bool MoreApples = Apple > Orange; bool FewerApples = Apple < Orange; if (FruitType == Fruit.Apple && MoreApples) { //do something } if (FruitType == Fruit.Orange && FewerApples) { //do something else }
Is there some better way to assign the enum to a var (or other way around??), and then have a Method call the chosen enum, and return the actual bool data in order to see if the IF is satisfied? Perhaps this is an array thing? I was hoping to use something like: FruitType == Fruit.XXX, with XXX pulling selected enum. Thank you all for helping the C# newbie -