Click here to Skip to main content
14,326,294 members
   

C#

 
GeneralRe: Copy text from console window Pin
Dave Kreskowiak10-Sep-19 3:13
mveDave Kreskowiak10-Sep-19 3:13 
GeneralRe: Copy text from console window Pin
Gene M10-Sep-19 7:39
memberGene M10-Sep-19 7:39 
GeneralRe: Copy text from console window Pin
Dave Kreskowiak10-Sep-19 8:49
mveDave Kreskowiak10-Sep-19 8:49 
GeneralRe: Copy text from console window Pin
Gene M10-Sep-19 11:28
memberGene M10-Sep-19 11:28 
GeneralRe: Copy text from console window Pin
Dave Kreskowiak10-Sep-19 11:43
mveDave Kreskowiak10-Sep-19 11:43 
GeneralRe: Copy text from console window Pin
Gene M10-Sep-19 13:03
memberGene M10-Sep-19 13:03 
Questioncall enum as argument in Method? Pin
Member 145823347-Sep-19 8:55
memberMember 145823347-Sep-19 8:55 
AnswerRe: call enum as argument in Method? Pin
Dave Kreskowiak7-Sep-19 10:31
mveDave Kreskowiak7-Sep-19 10:31 
Quote:
I want that enum to be the actual name of a var.

Nope. You don't get to do that. The values in an enum should not be thought of as variable names at all. Expanding that a little, if you have a string variable with the name of a variable as its value, that's also wrong.

It may work in interpreted languages, but it doesn't work in compiled languages. The variable names no longer exist(*).

* There is, of course, an exception. The namespaces, classes, method names, variables, and other code objects/names ARE available as metadata in .NET code. You access that data through the System.Reflection classes. Using reflection in your code will WAY over-complicate your code and reduce its performance. Reflection is not a quick thing. Don't do it unless you have a very specific reason and no other options.

In your example, your Calculate method should accept a parameter, FruitType. You don't appear to need the property at all. Of course, this makes assumptions that you don't show in your code nor explain in your question.
public override void Calculate(FruitType fruitType)

A method with the name Calculate also suggests it should return a value, which your code doesn't.

GeneralRe: call enum as argument in Method? Pin
BillWoodruff7-Sep-19 15:36
mveBillWoodruff7-Sep-19 15:36 
GeneralRe: call enum as argument in Method? Pin
Dave Kreskowiak7-Sep-19 17:21
mveDave Kreskowiak7-Sep-19 17:21 
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
protectorOriginalGriff7-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 
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
protectorOriginalGriff31-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
protectorOriginalGriff28-Aug-19 19:56 
AnswerRe: reading text file as an array by using streamreader Pin
Richard MacCutchan28-Aug-19 21:27
protectorRichard MacCutchan28-Aug-19 21:27 
QuestionRe: reading text file as an array by using streamreader Pin
Maciej Los28-Aug-19 21:42
protectorMaciej Los28-Aug-19 21:42 

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.