Archive for July 30, 2013

[C#] Enumeration Types Summary

An enumeration type (also named an enumeration or an enum) provides an efficient way to define a set of named integral constants that may be assigned to a variable.

Usually it is best to define an enum directly within a namespace so that all classes in the namespace can access it with equal convenience. However, an enum can also be nested within a class or struct.

Every enumeration type has an underlying type (byte, sbyte, short, ushort, int, uint, long, or ulong), which can be any integral type except char. The default underlying type of enumeration elements is int. To declare an enum of another integral type, such as byte, use a colon after the identifier followed by the type.

The default value of an enum E is the value produced by the expression (E)0, and the value of each successive enumerator is increased by 1 if it’s not explicitly assigned. When you create an enum, select the most logical default value and give it a value of zero, or you can consider creating a None enumerated constant. That will cause all enums to have that default value if they are not explicitly assigned a value when they are created.

When assigning values to the elements in the enumerator list, you can also use coputed values, for example:

enum MachineState
PowerOff = 0,
Running = 5,
Sleeping = 10,
Hibernating = Sleeping + 5

Read more

[VS] Solution to “Changes to 64-bit applications are not allowed”

One of the most popular features in the Visual Studio debugger is the ability to edit code during a debug session and have the changes apply without having to stop the debugger, recompile the application and then run the application to verify the changes. This feature is affectionately known as “Edit and Continue” or “E&C” for short.

Unfortunately, Edit and Continue isn’t supported on 64-bit. In fact, if you try to use Edit & Continue when debugging a 64-bit application, you get the following error message: “Changes to 64-bit applications are not allowed”, as shown below.

Read more