❔ List containing values that I am unsure how to represent as a type
How to accept a list of values as an argument where each value contains an actionName which is a string and an actionResult which is function?
5 Replies
What do I write to define the type of the function?
Ideally I would accept the actionName and actionResult through the constructor and assign the attributes there
I’m confused what you need. There’s two main types that hold functions:
Action
and Func
What does actionResult need to do?action result will just handle what ever the dialog option should do
A dialog option is a prompt in the console that has a number of options
for example
1. Option 1
2. Option 2
3. Option 3
I was going to represent an option inside of my program as a struct
Each option has a title (option 1, option 2 etc) and an actionResult. The action result is what fires when the choice is selected
so how do I accept a function in the constructor as an argument and then store it as a property in the struct to be used at a later date
In my case I think I just need an action
cause it does not return any value
Use an
Action
, which is a type which represents a method with no parameters and a void
return type.Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.