码迷,mamicode.com
首页 > 其他好文 > 详细

Variables

时间:2014-10-22 21:40:25      阅读:238      评论:0      收藏:0      [点我收藏+]

标签:io   os   ar   for   strong   sp   on   ad   bs   

// C# syntax for declaring variables merely specifi es the type and variable name:
// <type> <name>;
//
//
// Simple Types
//
// Integer Types
// TYPE      ALIAS FOR         ALLOWED VALUE
//
// sbyte     System.SByte    Integer between −128 and 127
// byte      System.Byte      Integer between 0 and 255
// short     System.Int16     Integer between −32768 and 32767
// ushort   System.UInt16   Integer between 0 and 65535
// int        System.Int32     Integer between −2147483648 and 2147483647
// uint      System.UInt32   Integer between 0 and 4294967295
// long     System.Int64     Integer between −9223372036854775808 and 9223372036854775807
// ulong   System.UInt64   Integer between 0 and 18446744073709551615
//
//
// -The u characters before some variable names are shorthand for unsigned, meaning that you can’t store
// -negative numbers in variables of those types
//
//
//
// Floating-point Types
// -float, double, decimal
//
//
// Text and Boolean Types
//
// TYPE    ALIAS FOR       ALLOWED VALUES
// char    System.Char     Single Unicode character, stored as an integer between 0 and 65535
// bool    System.Boolean  Boolean value, true or false
// string  System.String   A sequence of characters

 

 

Variable Naming

// -The basic variable naming rules are as follows:
// -1.The first character of a variable name must be either a letter, an underscore character(_), or the at
// -  symbol (@)
//
// -2.Subsequent characters may be letters, underscore characters, or numbers.
//
// aa, a_, a2,
// _a, __, _2,
// @a, @_, @2,
// 
//
//
// -Remember that C# is case sensitive
//
// -Naming Conventions
// -For your simple variables, stick to camelCase
// -use PascalCase for certain, more advanced naming

 

 

Variable Declaration and Assignment

// -declare variables simply using their type and name:
// ing age;
// age = 25;
//
// -NOTE: Remember that variables must be initialized before you use them. The
// -      preceding assignment could be used as an initialization
//
// -declare multiple variables of the same type at the same time by separating their names with commas after the type
// int xSize, ySize;
//
// -assigning values to variables when you declare them
// int age = 25;
// int xSize = 4, ySize = 5;
//
//
// int xSize, ySize = 5;
// -results in only ySize being initialized — xSize is just declared, and it still needs to be initialized before it’s used.

 

Variables

标签:io   os   ar   for   strong   sp   on   ad   bs   

原文地址:http://www.cnblogs.com/yoghourt/p/4044184.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!