C#学习笔记1

一、特殊运算符

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











发布了23 篇原创文章 · 获赞 5 · 访问量 2万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章