Micro Tips for .NET Developers
Clone this wiki locally
For those coming from the desktop / server .NET world, if you discover any differences with the .NET Micro Framework, please post them here.
- Enum.ToString() will not give you the name of the enumeration, only the numeric value.
- Generics are not supported.
- Neither the DateTime structure nor TimeZoneInformation have the method IsDaylightSavingTime()
- A bunch of TryParse methods (int.TryParse), etc.. are all missing as well; along with UTF8.GetString(byte), etc..
- Multidimensional arrays, wont compile string[,] foo= new string[10, 10]; If you need multi-dimensional arrays, you can create jagged arrays. As a side-benefit, the sub-arrays don't all need to be the same length.
- Avoid using the Microsoft.SPOT.Presentation namespace. You'll want to use the drawing primitives. We are looking at options to support common controls, but Microsoft.SPOT.Presentation.Controls is too resource-heavy at the moment. It's targeted toward devices that use more flash, RAM, and battery power.
- Small footprint is key! Avoid including any unnecessary images, fonts, or other resources that you absolutely do not need. Remove them before publishing.
- Avoid accessing resources in timer loops (for example the update timer for a watch face). It is better to get an instance to that resource (image, font, etc..) at the class or app level, and then re-use it in the loop.
- The Bitmap.Flush function has an overload which lets you specify a specific region of your UI that you want to push to the display Details on MSDN. Our display has memory-in-pixel technology, so we don't have to update the entire screen at once. We can simply update the rows of the display that have changed. So when you call Bitmap.Flush(...) with a set of coordinates, we only update display rows that fall within those coordinates. This is a good best-practice for writing energy efficient apps. But you can also just call Bitmap.Flush() with no coordinates and we'll take care of figuring out what to refresh for you. Our goal is to make it easy to develop apps while also providing tools that ensure long battery life for those apps.