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

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

Developing .NET Compact Framework apps in Post-2008 Visual Studio?

I’m positive this question is a duplicate, but for the life of me I can’t find the original so I’ll re-answer here. Microsoft’s support for Compact Framework development is not completely obvious or well documented. It’s a mixed matrix of the target version of Windows CE, the version of the Compact Framework and the version … Read more

Incorrectly aligned or overlapped by a non-object field error

The CF Marshaler isn’t so good at this type of thing and what you’re attempting is unsupported. The problem is that it knows that the first element is unaligned, but it seems to not understand that each element in the array would also be unaligned. You can see the behavior works in this example: [StructLayout(LayoutKind.Explicit, … 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