![](images/graphics/blank.gif)
Bài giảng Lập trình C# 2010: Chương 6 - ĐH Đồng Nai Công nghệ Đồng Nai
lượt xem 15
download
![](https://tailieu.vn/static/b2013az/templates/version1/default/images/down16x21.png)
Bài giảng Lập trình C# 2010: Chương 6 - String Class có nội dung trình bày về: Constructor, String Field, String Operators, String Methods, DEMO String & Dictionary.
Bình luận(0) Đăng nhập để gửi bình luận!
Nội dung Text: Bài giảng Lập trình C# 2010: Chương 6 - ĐH Đồng Nai Công nghệ Đồng Nai
- DONG NAI UNIVERSITY OF TECHNOLOGY
- DONG NAI UNIVERSITY OF TECHNOLOGY String Class Represents text as a series of Unicode characters.
- DONG NAI UNIVERSITY OF TECHNOLOGY Constructor There are many overload Constructors. I would like to tell you the Constructor below: String Constructor ( Char []) Initializes a new instance of the String class to the value indicated by an array of Unicode characters.
- DONG NAI UNIVERSITY OF TECHNOLOGY Constructor string strHUI = new string (new char[] {'H','U','I'}); Use string or String? MessageBox.Show(strHUI); String strHUI = new String (new char[] {'H','U','I'}); MessageBox.Show(strHUI);
- DONG NAI UNIVERSITY OF TECHNOLOGY String Fields Empty Represents the empty string. This field is read-only. string strName = string.Empty;
- DONG NAI UNIVERSITY OF TECHNOLOGY String Operators Name Description Equality(==) Determines whether “a”==“A”?false two specified strings “a”==“a”?true have the same value. Inequality(!=) Determines whether “a”!=“A”?true two specified strings “a”!=“a”?false have different values.
- DONG NAI UNIVERSITY OF TECHNOLOGY String Properties Name Description Chars Gets the character at a specified character position in the current String object. char ch = strHUI[0]; Length Gets the number of characters in the current String object. int nSize = strHUI.Length;
- DONG NAI UNIVERSITY OF TECHNOLOGY String Methods Name public static int Compare ( string strA, string strB ) Description Compares two specified String objects and returns an integer that indicates their relative position in the sort order 0 strA equals strB 1 strA is greater than strB -1 strA is less than strB
- DONG NAI UNIVERSITY OF TECHNOLOGY String Methods Example int nRet = string.Compare(“A", “a"); nRet=1 int nRet = string.Compare(“a", “A"); nRet=-1 int nRet = string.Compare(“a", “a"); nRet=0
- DONG NAI UNIVERSITY OF TECHNOLOGY String Methods Name public static int Compare( string strA, string strB, bool ignoreCase ) Description Compares two specified String objects ,ignoring or honoring their case, and returns an integer that indicates their relative position in the sort order
- DONG NAI UNIVERSITY OF TECHNOLOGY String Methods Example int nRet = string.Compare (“A", “a”,true);nRet=0 int nRet = string.Compare (“a", “A”,false);nRet=-1 int nRet = string.Compare (“A", “a”,false);nRet=1
- DONG NAI UNIVERSITY OF TECHNOLOGY String Methods Name public int CompareTo( string strB ) Description Compares this instance with a specified String object and indicates whether this instance precedes, follows, or appears in the same position in the sort order as the specified String. (0 ; 1 ; -1)
- DONG NAI UNIVERSITY OF TECHNOLOGY String Methods Example string strA = “A”; string strB = “B”; int nRet = strA.CompareTo(strB); nRet=-1 string strA = “A”; string strB = null; int nRet = strA.CompareTo(strB); nRet=1
- DONG NAI UNIVERSITY OF TECHNOLOGY String Methods Name public static string Copy(string str) Description Creates a new instance of String with the same value as a specified String. string str = string.Copy("Teo"); string str1 = "Ti"; string str2 =string.Copy(str1);
- DONG NAI UNIVERSITY OF TECHNOLOGY String Methods Name public bool Contains( string value ) Description Returns a value indicating whether the specified String object occurs within this string Return true or false
- DONG NAI UNIVERSITY OF TECHNOLOGY String Methods Example string strA = "Trần Văn Tèo"; string strB = "Văn"; bool bRet = strA.Contains(strB); if (!bRet) MessageBox.Show("Không có ["+strB+"] trong ["+strA+"]"); else MessageBox.Show("Có [" + strB + "] trong [" + strA + "]");
- DONG NAI UNIVERSITY OF TECHNOLOGY String Methods Name public bool EndsWith( string value ) Description Determines whether the end of this string instance matches the specified string Return true or false
- DONG NAI UNIVERSITY OF TECHNOLOGY String Methods Example string strA = "Tèo "; string strB = ""; bool bRet = strA.EndsWith(strB); if (bRet) MessageBox.Show("có [" + strB+"] ở cuối chuỗi"); else MessageBox.Show("Ko có [" + strB + "] ở cuối chuỗi");
- DONG NAI UNIVERSITY OF TECHNOLOGY String Methods Name public bool EndsWith( string value, StringComparison comparType ) Description Determines whether the end of this string instance matches the specified string when compared using the specified comparison option
- DONG NAI UNIVERSITY OF TECHNOLOGY String Methods Example string strA = "Tèo"; string strB = ""; bool bRet = strA.EndsWith(strB, StringComparison.OrdinalIgnoreCase); if (bRet) MessageBox.Show("có [" + strB+"] ở cuối chuỗi"); else MessageBox.Show("Ko có [" + strB + "] ở cuối chuỗi");
![](images/graphics/blank.gif)
CÓ THỂ BẠN MUỐN DOWNLOAD
-
Bài giảng Lập trình Windows bằng C Sharp (C#) - GV. Nguyễn Thành Chiến
38 p |
233 |
70
-
Bài giảng Lập trình Windows - Phạm Ngọc Hưng (ĐH Bách Khoa)
312 p |
241 |
54
-
Hướng dẫn thực hành lập trình C trên Visual Studio
9 p |
1354 |
31
-
Bài giảng Lập trình C# 2010: Chương 1 - ĐH Công nghệ Đồng Nai
42 p |
128 |
21
-
Bài giảng Lập trình C# 2010: Chương 2 - ĐH Công nghệ Đồng Nai
46 p |
111 |
21
-
Bài giảng Lập trình C# 2010: Chương 2.3 - ĐH Công nghệ Đồng Nai
21 p |
100 |
19
-
Bài giảng Lập trình C# 2010: Chương 3 - ĐH Công nghệ Đồng Nai
47 p |
107 |
18
-
Bài giảng Lập trình C# 2010: Chương 2.4 - ĐH Công nghệ Đồng Nai
16 p |
92 |
18
-
Bài giảng Lập trình C# 2010: Chương 4 - ĐH Công nghệ Đồng Nai
69 p |
112 |
17
-
Bài giảng Lập trình C# 2010: Chương 2.2 - ĐH Công nghệ Đồng Nai
57 p |
85 |
15
-
Bài giảng Lập trình C# 2010: Chương 5 - ĐH Công nghệ Đồng Nai
22 p |
102 |
15
-
Bài giảng Lập trình C# 2010: Chương 1.1 - ĐH Công nghệ Đồng Nai
17 p |
117 |
14
-
Bài giảng: Lập trình trên Windows với Microsoft® .NET
11 p |
93 |
12
-
Bài giảng Kỹ thuật lập trình nâng cao: Chương 1 - ThS. Dương Thành Phết
52 p |
66 |
7
-
Bài giảng Thiết kế và lập trình Website: Chương 0 - ThS. Dương Thành Phết
13 p |
75 |
6
-
Bài giảng Lập trình giao diện: Chương 1 - Nguyễn Thị Mai Trang
23 p |
46 |
4
![](images/icons/closefanbox.gif)
![](images/icons/closefanbox.gif)
Chịu trách nhiệm nội dung:
Nguyễn Công Hà - Giám đốc Công ty TNHH TÀI LIỆU TRỰC TUYẾN VI NA
LIÊN HỆ
Địa chỉ: P402, 54A Nơ Trang Long, Phường 14, Q.Bình Thạnh, TP.HCM
Hotline: 093 303 0098
Email: support@tailieu.vn
![](https://tailieu.vn/static/b2013az/templates/version1/default/js/fancybox2/source/ajax_loader.gif)