C#学习笔记1

来源:互联网 发布:网络覆盖公司 编辑:程序博客网 时间:2024/05/16 13:54

一、特殊运算符

1、is 运算符

用于检查变量是否是指定的类型。
<span style="white-space:pre"></span>int i = 0;<span style="white-space:pre"></span>bool result = i is int;

二、字符串的相关方法

1、比较字符串

<span style="white-space:pre"></span>Int Compare(string strA, string strB)<span style="white-space:pre"></span>Int Compare(string strA, string strB, bool ignoreCase)
<span style="white-space:pre"></span>CompareTo方法与Compare相似,不同的是CompareTo方法以实力对象本身与指定的字符串作比较
<span style="white-space:pre"></span>Equal比较两个字符串是否相同
</pre><h2><span style="white-space:pre"><span style="white-space:pre">2</span>、</span>格式化字符串</h2></div><div><span style="white-space:pre"></span>用静态方法Format   </div><div><span style="white-space:pre"></span><a target=_blank href="http://http://msdn.microsoft.com/zh-cn/library/system.string.format(v=vs.110).aspx">string.Format</a></div><h2>3、分割字符串</h2><div><span style="white-space:pre"></span><pre name="code" class="csharp">string[] str1 = str.Split(separator)

、可变字符串类StringBuilder

用String类型定义的字符串是不可修改的,表面上看到的对字符串所做的修改操作,实际在计算机的内存中都会声称一个新的字符串。当需要大量修改字符串时,可以用StringBuilder
<span style="white-space:pre"></span>public StringBuilder()<span style="white-space:pre"></span>public StringBuilder(string value)<span style="white-space:pre"></span>public StringBuilder(int capacity)<span style="white-space:pre"></span>public StringBuilder(string value, int capacity)
<span style="white-space:pre"></span>Append <span style="white-space:pre"></span>AppendFormat<span style="white-space:pre"></span>Insert <span style="white-space:pre"></span>Remove <span style="white-space:pre"></span>Replace











0 0
原创粉丝点击