- Home /
relate two variables
Hi, I want to make an array with some type of variables...I don't know what kind will be better yet. I want to relate the elements in the array with other variables. For example I have a list with meat, fruit, vegetable and it can take for example: meat = pork, fruit = orange, vegetable = carrot.
so when I start the game if the variable in the array is null it takes one of the values I choose in the game and it will be the value until I change it... I don't know if I'm making this clear.
Thanks for your help in advance.
do you want separate lists or a combined list with 1 of each type?
What do you want to achieve after you have such lists?
Answer by Glurth · Oct 18, 2017 at 07:29 PM
I'm not quite sure I understand the question, but if I do, this is how I would implement something like that. I threw in foodName and calories as examples of other "class members".
public enum TypeOfFood {meat, fruit, vegetable};
public class FoodObject
{
public string foodName;
public int calories;
public TypeOfFood typeOfFood;
}
maybe it would work. I'll try and later I will return to say if it worked. Thanks.
Your answer
Follow this Question
Related Questions
Instantiate multiple objects from an array 1 Answer
Failed setting triangles in my mesh 1 Answer
Problem with List 0 Answers