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萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章