- Home /
 
 
               Question by 
               Marshal_Alessi · Feb 24, 2016 at 03:01 AM · 
                floatvaluedictionaryvalues  
              
 
              Dictionary doesn't exist?
 public class StockMarket : MonoBehaviour {
 
 
     public Dictionary<string, float> StockNames;
 void Start(){
         StockNames.Add("ChickenNFries_S", 68.41f);
 }
 
 Even that short bit of code is returning the error: "Object Reference not set to an Instance of an object"(20) which would be the StockNames.Add bit.
 Any idea why?
 
              
               Comment
              
 
               
              Answer by jgodfrey · Feb 24, 2016 at 03:13 AM
You never actually created the dictionary. You probably want this:
 public Dictionary<string, float> StockNames = new Dictionary<string, float>();
 
              Your answer
 
             Follow this Question
Related Questions
Have a problems with a values 1 Answer
Can't assign dictionary values 0 Answers
Accessing float from dictionary 2 Answers
Change value according to Y position of an object? 2 Answers
How do I create a Key and Values Dictionary array in C# 1 Answer