What does the /target: command line option do in the C# compiler?

All the /target: options except module create .NET assemblies. Depending on the option, the compiler adds metadata for the operating system to use when loading the portable executable (PE) file and for the runtime to use in executing the contained assembly or module. module creates a module. The metadata in the PE does not include… Read more

What is the difference between const and static readonly?

The difference is that the value of a static readonly field is set at run time, and can thus be modified by the containing class, whereas the value of a const field is set to a compile time constant. In the static readonly case, the containing class is allowed to modify it only in the… Read more

How do I create a constant that is an array?

Strictly speaking you can’t, since const can only be applied to a field or local whose value is known at compile time. In both the lines below, the right-hand is not a constant expression (not in C#). const int [] constIntArray = newint [] {2, 3, 4}; // error CS0133: The expression being assigned to… Read more

How do I get and set Environment variables?

Use the System.Environment class.Specifically the GetEnvironmentVariable and SetEnvironmentVariable methods. Admitedly, this is not a question specific to C#, but it is one I have seen enough C# programmers ask, and the ability to set environment variables is new to the Whidbey release, as is the EnvironmentVariableTarget enumeration which lets you separately specify process, machine, and… Read more