tailieunhanh - Bài giảng Lập trình C# 2010: Chương 6 - ĐH Đồng Nai Công nghệ Đồng Nai
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. | 1 String Class Represents text as a series of Unicode characters. 2 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. 3 Constructor string strHUI = new string (new char[]{H,U,I}); (strHUI); String strHUI = new String (new char[]{H,U,I}); (strHUI); Use string or String? 4 String Fields Empty Represents the empty string. This field is read-only. string strName = ; 5 String Operators Name Description Equality(==) “a”==“A”?false “a”==“a”?true Determines whether two specified strings have the same value. Inequality(!=) “a”!=“A”?true “a”!=“a”?false Determines whether two specified strings have different values. 6 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 = ; 7 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 8 String Methods Example int nRet = (“A", “a"); nRet=1 int nRet = (“a", “A"); nRet=-1 int nRet = (“a", “a"); nRet=0 9 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 10 String Methods Example int nRet = (“A", “a”,true); nRet=0 int nRet = (“a", “A”,false); nRet=-1 int nRet = (“A", “a”,false); nRet=1 11 String Methods Name public . | 1 String Class Represents text as a series of Unicode characters. 2 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. 3 Constructor string strHUI = new string (new char[]{H,U,I}); (strHUI); String strHUI = new String (new char[]{H,U,I}); (strHUI); Use string or String? 4 String Fields Empty Represents the empty string. This field is read-only. string strName = ; 5 String Operators Name Description Equality(==) “a”==“A”?false “a”==“a”?true Determines whether two specified strings have the same value. Inequality(!=) “a”!=“A”?true “a”!=“a”?false Determines whether two specified strings have different values. 6 String Properties Name Description Chars Gets the character at a specified character position in the current String object. char ch = strHUI[0]; .
đang nạp các trang xem trước