Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am making a Roulette game in Unity 5.0. I have a list in C# where I store the bets the player places. I use the following code to retrieve the bets placed by the user. Bets1 is the list which saves the type of bet placed by the user like SUP0 is straight up bet on Number 0, SPLT1 is split bet on number 1 & 2. These SUP0 and SPLT1 are lists in which these numbers are added.

for (int i = 0; i < Bets1.Count; i++)
    {
        string a = Bets1[i].listname;

        Debug.Log(a);
        //the output in console is SUP0 for Straight up bet on number 0

        for (int j = 0; j < a.Count; j++)
        {
            Debug.Log(a[i]);
        }
}

The above code shows error on a.Count and a[i]. My question is how to assign the value of variable a to be used as name of predefined list.

share|improve this question
    
List<Bets> Bets1 = new List<Bets>(); and Bets is a class public class Bets { public string listname; public GameObject GameObj; public int betamount; } – Jayesh Duggal Mar 17 at 13:11
    
You are right. There is no list in Bets Class. But the name of the List in which bet numbers are stored is saved as string in public string listname. For example if a split bet is placed by the user(for example SPLT1). The name of the list which has the numbers (for ex. SPLT1) is saved in listname. So should I add the listt SPLT1 in class Bets ratther than string listname. – Jayesh Duggal Mar 17 at 13:19
    
How to do that? – Jayesh Duggal Mar 17 at 13:21
    
Can i put the entire list in Bets – Jayesh Duggal Mar 17 at 13:22
    
I populate these lists like SPLT1, SPLT2, etc in start function. I populate Bets in on of the function when user places one of the bets. If user places 5 bets, 5 Bets are put in Bets1. – Jayesh Duggal Mar 17 at 13:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.