using system;using system.collections.generic;using system.linq;using system.text; Namespace _3. Variable { class program { static void main (String[] args) { // integer Types sbyte mySbyte = 45; byte myByte = (byte) mysbyte; console.writeline ("mySbyte = {0} ", mysbyte); Console.WriteLine ("Mybyte = {0}", mybyte); int myInt = 486255; console.writeline ("myint = {0}", myInt); float myFloat = 3.14F; console.writeline ("myfloat = {0}", myfloat); bool myBool1 = true, myBool2; myBool2 = false; console.writeline ("mybool1 = {0}", mybool1); &nbSp; console.writeline ("mybool2 = {0}", mybool2); Console.readkey (); } }}/** * A , the basic concept of variables * (1) variable is a name for the program to manipulate the store. * (2) Each variable has a specific type, and the type determines the memory size and layout of the variable. * * naming rules for variables * (1) variable names by numbers, letters, underscores (_), and @. * (2) cannot start with a number. * (3) cannot use keywords as variable names. * * syntax for declaring variables * <data_type> <variable_list>; * * parameter Parsing: * <data_type>: valid C # data types. * <variable_list>: one or more comma-delimited identifiers. * * Initialization of variables * (1) declaring variables before initializing * <variable_name> = <value>; * * parameter parsing: * <variable_name>: variable name * <value>: value * * (2) Initialize when declaring a variable * <data_type> <variable_name> = <value>; * * parameter analysis: &NBSP;*&NBSP;<DATA_TYPE>: Valid C # data types * <variable_name>: variable names * <value>: values * * Note: Using uninitialized variables results in compilation errors. * * Five, Lvalue, and rvalue * <lvalue>: lvalue expressions can appear to the left and right of an assignment statement. An * <rvalue>: rvalue expression can appear to the right of an assignment statement, but not to the right of an assignment statement. The * * variable is <lvalue>, and the value is <rvalue>. * * vi. Variable Command conventions * (1) pascalcase naming conventions * eg. * int age; * string lastname; * double WinterOfDiscontent; * * (2) CamelCase Naming Conventions * eg. * int age; * string firstName; * double timeofdeath; */
This article is from the "MK IT Life" blog, so be sure to keep this source http://vikxiao.blog.51cto.com/9189404/1585717
Third, variable