Tuesday, July 16, 2013

How to differentiate versions WinCE from Win Mobile

In the past few months, due to professionals reasons, I've been doing a lot of development for Windows embedded devices (mainly barcode scanners) so I had to come up with some adjustments to the layout of the applications in the different devices it will be running on. Some run Windows CE, others run Mobile. To detect the right type of device I wrote the following code.



This code returns a string, this string can be anything. My experience gave me this rule, that might not be a definitive rule. If you're running a WinCE device you'll get, normally, the model of the device, ex: FalconX3). And "PocketPC" or "Smartphone" in devices based on Windows Mobile. References: Ref 1 Ref 2

Wednesday, July 10, 2013

Hide the border of a ListBox

I made this simple auxiliary class to toggle the visibility of a ListBox in C# for the MS.Net Compact Framework.


Read

Tuesday, June 25, 2013

Curly braces in C# string.Format()

That awkward moment you discover you don't know how to escape the curly braces inside the formatter string in the string.Format() method in C#. That's right, I've been using this method for at least two years now, and I was never confronted with this situation. Well, it's fairly easy to go around the problem, just use double braces {{ or }} and you'll get something like the following:

String.Format("public {0} {1} {{ get; private set; }}", 
prop.Type, prop.Name)

Info

The @ sign in C#

The @ symbol serves 2 purposes in C#:
#1 allows you to use a reserved keyword as a variable like this:
int @int = 15;
#2 lets you specify a string without having to escape any characters. For instance the '\' character is an escape character so typically you would need to do this:
var myString = "c:\\myfolder\\myfile.txt"
alternatively you can do this:
var myString = @"c:\myFolder\myfile.txt"
Info