Blog - Title

December, 2004

  • The C# Team

    What is the difference between const and static readonly?

    • 11 Comments
    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, w hereas the value of a const field is set to a compile time constant. In the static readonly case, the containing class...
  • The C# Team

    How do I create a constant that is an array?

    • 8 Comments
    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...
  • The C# Team

    How do I get and set Environment variables?

    • 6 Comments
    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...
  • The C# Team

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

    • 5 Comments
    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...
Page 1 of 1 (4 items)