Micro Tips for .NET Developers - nothingmn/AGENT.Contrib GitHub Wiki

Source: http://forums.agentwatches.com/index.php?/topic/6-micro-tips-for-net-developers/

For those coming from the desktop / server .NET world, if you discover any differences with the .NET Micro Framework, please post them here.

  1. Enum.ToString() will not give you the name of the enumeration, only the numeric value.
  2. Generics are not supported.
  3. Neither the DateTime structure nor TimeZoneInformation have the method IsDaylightSavingTime()
  4. A bunch of TryParse methods (int.TryParse), etc.. are all missing as well; along with UTF8.GetString(byte[]), etc..
  5. 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.
  6. 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.
  7. Small footprint is key! Avoid including any unnecessary images, fonts, or other resources that you absolutely do not need. Remove them before publishing.
  8. 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.
  9. 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.