Click here to Skip to main content
14,356,787 members
   

C#

 
GeneralRe: Copy text from console window Pin
Richard MacCutchan9-Sep-19 22:16
protectorRichard MacCutchan9-Sep-19 22:16 
GeneralRe: Copy text from console window Pin
Dave Kreskowiak10-Sep-19 4:13
mveDave Kreskowiak10-Sep-19 4:13 
GeneralRe: Copy text from console window Pin
Gene M10-Sep-19 8:39
memberGene M10-Sep-19 8:39 
GeneralRe: Copy text from console window Pin
Dave Kreskowiak10-Sep-19 9:49
mveDave Kreskowiak10-Sep-19 9:49 
GeneralRe: Copy text from console window Pin
Gene M10-Sep-19 12:28
memberGene M10-Sep-19 12:28 
GeneralRe: Copy text from console window Pin
Dave Kreskowiak10-Sep-19 12:43
mveDave Kreskowiak10-Sep-19 12:43 
GeneralRe: Copy text from console window Pin
Gene M10-Sep-19 14:03
memberGene M10-Sep-19 14:03 
Questioncall enum as argument in Method? Pin
Member 145823347-Sep-19 9:55
memberMember 145823347-Sep-19 9:55 
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 -
AnswerRe: call enum as argument in Method? Pin
Dave Kreskowiak7-Sep-19 11:31
mveDave Kreskowiak7-Sep-19 11:31 
GeneralRe: call enum as argument in Method? Pin
BillWoodruff7-Sep-19 16:36
mveBillWoodruff7-Sep-19 16:36 
GeneralRe: call enum as argument in Method? Pin
Dave Kreskowiak7-Sep-19 18:21
mveDave Kreskowiak7-Sep-19 18:21 
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 
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 

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.