I am not able to use declaration List<...>. with Visual C# 2010 Express.
Where could be a problem?
  | ||||||||||||||
uning List<struct>
Started by mrsupe, Aug 10 2013 06:42 PM
5 replies to this topic
#1Posted 10 August 2013 - 06:42 PM I am not able to use declaration List<...>. with Visual C# 2010 Express. Where could be a problem?
#2Posted 11 August 2013 - 03:51 AM
Hi mrsupe,
Generics are not supported in the .NET Micro Framework. You can use arrays, jagged arrays, and collections though.
Welcome to the Netduino community,
Chris
#3Posted 22 December 2013 - 09:34 PM Without generics, I like to create my own collection class to ensure type safety by including methods for adding and removing objects of a certain type. The class uses an ArrayList as its internal collection. The nice thing is that you can ensure that all of the items in the collection are of the expected type. Check out my Netduino projects on GitHub. #4Posted 12 February 2014 - 04:04 PM Hi,
I would like to do something with an object having it's name/id. For example:
module sensor = new module { id = 47, name = "tempSensor" value = 0, };
later in code I read sensor name (i. e. from UART) and put it to string: string sensorString = "<sensorname or id>";
Now I would like to set some value to it - how can I do that? <sensorname>.value = 100
I was thinking about dictionary (<string, module>) but while its missing in MF I dont know what would be the best method to accomplish that? #5Posted 14 February 2014 - 06:52 AM you can use a Hashtable, with the name being the key. Hashtable has untyped object references only, so you need to cast the lookup value somehow like that ((myhashtable[componentname]) as MyModuleType).Value = 100
At that time you need to know the type of the module, so best way is if all the module are the same type or derive from a common base class. #6Posted 14 February 2014 - 08:08 AM
Hey,
I've tried to use object array instead of many individual objects and now can navigate them through array index.
I will try your solution also - thanks for help
0 user(s) are reading this topic0 members, 0 guests, 0 anonymous users | ||||||||||||||
|
||||||||||||||
This webpage is licensed under a Creative Commons Attribution-ShareAlike License. | ||||||||||||||