First of all, these interviews will often be asked by the interviewer, but you answer to the interviewer satisfaction? Of course, if you know these principles, you may not
Afraid of. Since we're talking about the principle, we'll start with MSDN.
A: A few places worth scrutiny
1. Let's take a look at MSDN above on how const is said, we will see. Cannot be modified, compile the constant amount of these critical information.
Why Q:const cannot be modified.
A: This is very simple, and many textbooks say that when the compiler compiles, the values of the constants are stored in the assembly's metadata, and we do an example
Take a look at it.
①: Create a new projecta.
The code is as follows:
ProjectA
public class TestClass
{
public const int Ctrip = Int. MaxValue;
}
Build another mainproject, quoting the next projecta.
The code is as follows:
Using System;
Class Program
{
static void Main (string[] args)
{
Console.WriteLine (Testclass.ctrip);
Console.read ();
}
}
In addition to the Declaration,
Running GuestArticles are original, reproduced please link to the form of the address of this article
In-depth discussion of const, readonly keywords in C #
This address: http://www.paobuke.com/develop/c-develop/pbk23667.html
Related content C # implementation sequence table (linear table) A complete example of how to resolve a hash conflict common misconception of the Equals method in C # Implementation of the method of controlling the volume and mute of the system based on the Add-minus button
C # Methods for reading computer CPU and HDD Information C # Managed heap object instance contains content Analysis C # implementation method for automatically adding copyright annotation information to class and function code C # implementation terminates executing thread
In-depth discussion of const, readonly keywords in C #