What are the most valuable .Net Compact Framework Tips, Tricks, and Gotcha-Avoiders? [closed]

Sure: Use a physical device whenever possible (not the emulator) Test with multiple devices (different vendors, different models) Concentrate testing around sleep/wakeup behaviors When using MSTEST unit tests, never use private accessors Avoid ActiveSync like the plague – debug using CoreCon direct Get familiar with RPM and start using it early Reuse objects when possible … Read more

How best to read a File into List

var logFile = File.ReadAllLines(LOG_PATH); var logList = new List<string>(logFile); Since logFile is an array, you can pass it to the List<T> constructor. This eliminates unnecessary overhead when iterating over the array, or using other IO classes. Actual constructor implementation: public List(IEnumerable<T> collection) { … ICollection<T> c = collection as ICollection<T>; if( c != null) { … Read more

Center text output from Graphics.DrawString()

I’d like to add another vote for the StringFormat object. You can use this simply to specify “center, center” and the text will be drawn centrally in the rectangle or points provided: StringFormat format = new StringFormat(); format.LineAlignment = StringAlignment.Center; format.Alignment = StringAlignment.Center; However there is one issue with this in CF. If you use … Read more

Function that creates a timestamp in c#

I always use something like the following: public static String GetTimestamp(this DateTime value) { return value.ToString(“yyyyMMddHHmmssfff”); } This will give you a string like 200905211035131468, as the string goes from highest order bits of the timestamp to lowest order simple string sorting in your SQL queries can be used to order by date if you’re … Read more

tech