-1

I have values that have decimals that I would like to store in a dictionary for easy access. However in C# it only allows a string and an int. Is there another way I can achieve similar results?

This is my code:

   littledictionary.Add("price", (float)0.0);
   littledictionary["price"] = (float)SQLreader["price"];
McGarnagle
  • 101,349
  • 31
  • 229
  • 260
user999690
  • 257
  • 4
  • 10
  • 23

2 Answers2

6

What do you mean? You can use a float-based dictionary:

var littledictionary = new Dictionary<string,float>();
littledictionary.Add("price", (float)0.0);
McGarnagle
  • 101,349
  • 31
  • 229
  • 260
0

Or alternatively you can use List:

List<Decimal> list1 = new List<decimal>();

You can see how to use lists here: http://www.dotnetperls.com/list

Hope this helps.

03Usr
  • 3,335
  • 6
  • 37
  • 63