The previous section has a variable. The end is simple to say the following naming method, declaring variables.
Naming is a very important knowledge in C #, or any language. Worth thinking deeply about. The optimization of variable name and its efficiency increase, there are many big relationship.
Declare the variable, which is described in the next section.
There are many interesting ways to declare it. For example
int age; // declares a variable of type int named age age=0; // Assign Value /* or is that so? */ int Schoolnub, Classnub; Schoolname=n; Classnub=1; /* in a mix or two. */ int stdnub=; Xsize=;
The essence of a variable is that the value can be stored in it and can be taken out or viewed. So are they interchangeable? Of course. As I said, there are different types of storage based on different values. There are certain requirements for all swaps.
This is divided into implicit numeric conversions, explicit numeric conversions.
What is implicit and what is an explicit type? Answer: implicit direct conversion. Explicit is required for a specific notation. As for how to operate let's look at the list of implicit conversions first. The following list of the preceding types can be converted directly to the later.
This is an example where implicit conversions apply only to this list.
int nub=ten; // declares an int type named NUB and assigns a value of Long L // declares a long type L=NUB; // implicitly-assigned values
l=10;
When we're going to change something else? This is the time to explicitly convert. The following list lists the display transformations with some of their comments. An explicit conversion differs from an implicit conversion. Some unexpected things can happen at the time of conversion. There may be some errors in the value. Should be a cast for which it is a part. As for the values that change, refer to the range of value types in the previous section http://www.cnblogs.com/T-ARF/p/6262303.html. I told you to remember the range of values. Can't remember that is not vague to go to Baidu is not "I think almost on the".
The format of the explicit conversion (changetype) is the type in parentheses that is to be converted, and the outside is the current type
To an example
Double 1234.7 ; int A; /* */ = (int) x; Fixed Syntax format (type) type Console.WriteLine (a); // output a=1234
See, the value of the cast and the start value are not the same. Has changed. So make sure your values are what you want, or can be used, before casting the explicit conversion.
C#_ variables and transformations in the Confucian classics: "C # Getting Started classic"