tailieunhanh - Bài giảng Lập trình C# 1 - Chương 7: Strings
Bài giảng Lập trình C# 1 - Chương 7: Strings giới thiệu tới các bạn về Characters and Strings, String Constructors, String Indexer, Length Property and CopyTo Method, Comparing strings, Locating Characters and Substrings in strings, Extracting Substrings from strings. | F -X C h a n ge PD F -X C h a n ge N y bu om k lic tr ac .c C om k lic C .c re . . k e r- s o ft w a w w ac ww ww tr to to bu y N O W ! 17/05/2011 O W ! PD k e r- s o ft w a Contents Ch ng 7 STRINGS • • • • • • • • • • Characters and Strings String Constructors String Indexer, Length Property and CopyTo Method Comparing strings Locating Characters and Substrings in strings Extracting Substrings from strings Concatenating strings String methods Replace, ToLower, ToUpper and Trim StringBuilder class constructors Char Methods Characters and Strings • Characters : – Decimal digits – Letters – Special symbols string color = "blue"; • Strings : – p h p các Characters – Bao g m: • Decimal digits • Letters • Special symbols string file = "C:\\MyFolder\\MySubFolder\\"; string file = @"C:\MyFolder\MySubFolder\"; 1 re F -X C h a n ge PD F -X C h a n ge N y bu string Constructors string string0, string1, string2, string3, string4; char[] characterArray = { 'b', 'i', 'r', 't', 'h', ' ', 'd', 'a', 'y' }; string0 = "Welcome to C# programming!"; string1 = string0; string2 = new string( characterArray ); string3 = new string( characterArray, 6, 3 ); string4 = new string( 'C', 5 ); ( "string1 = " + "\"" + string1 + "\"\n" + "string2 = " + "\"" + string2 + "\"\n" + "string3 = " + "\"" + string3 + "\"\n" + "string4 = " + "\"" + string4 + "\"\n" ); Comparing strings ( "hello" ) ( string3, string4 ) string1 == "hello“ ( string2 ) //0; 1;-1 strings[ i ].StartsWith( "st" ) strings[ i ].EndsWith( "ed" ) om k lic tr ac .c C om k lic C .c re . . k e r- s o ft w a w w ac ww ww tr to to bu y N O W ! 17/05/2011 O W ! PD k e r- s o ft w a string Indexer, Length Property and CopyTo Method string string1; char[] characterArray; string1 = "hello there"; characterArray = new char[ 5 ]; ( "string1: \"" + string1 + "\"" .
đang nạp các trang xem trước