C# Frequently Asked QuestionsThe C# team posts answers to common questionsWhat does the target: command line option do in the C compiler- December 5, 2004 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 a manifest. Modules + manifest make an assembly - the smallest unit of deployment. Without the metadata in the manifest, there is little the runtime can do with a...http://blogs.msdn.com/csharpfaq/archive/2004/12/04/275229.aspx What is the difference between const and static readonly- December 3, 2004 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 variable declaration (through a variable initializer) in the static constructor (instance constructors, if it's not static) static readonly is typically used if the type of the field is not allowed in a const...http://blogs.msdn.com/csharpfaq/archive/2004/12/03/274791.aspx How do I create a constant that is an array- December 3, 2004 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 'constIntArray' must be constant const int constIntArrayAnother = 2, 3, 4; error CS0623: Array initializers can only be used in a variable or field initializer. Try using a new...http://blogs.msdn.com/csharpfaq/archive/2004/12/03/274417.aspx How do I get and set Environment variables- December 2, 2004 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 user. Brad Abrams blogged on this way back at the start of this year, and followed up with a solution...http://blogs.msdn.com/csharpfaq/archive/2004/12/02/273785.aspx |