C#是区分大小写的。
int wholePart = 10;
int Wholepart = 20;
是不同的变量定义。
合法的变量名以字母或下划线为首字母,后面可以跟随一个或多个字母、下划线或数字。
int 9abc; //illegal, starts with an integer
int _abc; //legal, starts with an underscore
int _9abc; //legal, starts with an underscore, and follow with multi-characters
int #myAge; //illegal, starts with an illegal character
int myAge_1; //legal, starts with a char followed by
P40
StringBuilder
StringBuilder类直接操作并管理字符数组,这样能够提高性能。有了这个方法,就不必经常分配新字符串了。这样就避免了使用标准字符串函数和串联时,垃圾回收器不断跟踪并回收小块内存的情况,从而提高了性能。StringBuilder类位于System.Text命名空间。
- using System;
- using System.Text;
- namespce test
- {
- class test
- {
- static void Main(string[] args)
- {
- StringBuilder stmBuilder = new StringBuilder("select from table");
- Console.WriteLine("Please enter to select columns");
- string columns = Console.ReadLine();
- stmBuilder.Insert(7, columns);
- //insert a space in front of from
- stmBuilder.Insert(7+columns.Length, " ");
- Console.WriteLine(stmBuilder.ToString());
- }
- }
- }
输入: FirstName, LastName 输出为:select FirstName, LastName from table。在用户要动态添加查询字段或者选择字段时,可以派上用场。像淘宝做的项目划分一样。