C#技术内幕(2)

 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命名空间。

  1. using System;
  2. using System.Text;
  3. namespce test
  4. {
  5.   class test
  6.    {
  7.      static void Main(string[] args)
  8.       {
  9.          StringBuilder stmBuilder = new StringBuilder("select from table");
  10.          Console.WriteLine("Please enter to select columns");
  11.          string columns = Console.ReadLine();
  12.          stmBuilder.Insert(7, columns);
  13.          //insert a space in front of from
  14.          stmBuilder.Insert(7+columns.Length, " ");
  15.          Console.WriteLine(stmBuilder.ToString());
  16.       }
  17.    }
  18. }

输入: FirstName, LastName 输出为:select FirstName, LastName from table。在用户要动态添加查询字段或者选择字段时,可以派上用场。像淘宝做的项目划分一样。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值