untitled

Similar documents
untitled

untitled

untitled

untitled

九十三年第三期檔案管理工作研習營學員建議事項答覆情形彙整表

台灣經濟新報資料庫

untitled

I/O Files讀寫檔案:

untitled

Microsoft PowerPoint - ch5.pptx

中華人民共和國殘疾人保障法(2008年修訂)

了 立 連 立 量 領 來 例 蘭 便 不 數 不 論 更 更 更 力 更 參 例 來 例 見 量 度 量 量 參 論 量 行 量 量 瑩 理 來 錄 量 量 不 力 省 力 立 力 量 量 量 了 量 便 錄 錄 錄 料 說 省 6

臺灣地區的警察教育現況與展望

大陸黨報集團化發展之研究

untitled

微處理機實習期末專題

untitled

untitled

untitled

untitled

untitled

untitled

untitled

人身保險業務員資格測驗方案

移民資料

untitled

1

PowerPoint 簡報

untitled

untitled

untitled

地方公共服務績效比較評量之探討—標竿學習策略的觀點

第五章 實例個案

untitled

untitled

untitled

untitled

富春國小主題統整課程計畫表 每年級(教學群)至少三個主題

untitled

第五章 鄉鎮圖書館閱讀推廣活動之分析

4-04 論文封面(樣式)

untitled

untitled

untitled

嘉義市都市計畫保護區農業區土地使用審查要點(草案)

untitled

吃寒天真的能減肥嗎

個人教室 / 網路硬碟

untitled

untitled

untitled

untitled

untitled

untitled

untitled

untitled

untitled

國立陽明大學輻射防護計畫書

untitled

untitled

untitled

十四、特殊需求的嬰兒

untitled

untitled

untitled

94年度學習障礙補救教學進階研習

PowerPoint 簡報

隱形眼鏡的世界

untitled

untitled

untitled

四湖鄉志纂修

untitled

untitled

龍華科技大學

untitled

中華民國第45屆中小學科學展覽會

untitled

行政院國科會九十一年度專題研究

untitled

untitled

第三章 我國非營業特種基金制度及運作現況

untitled

untitled

untitled

untitled

1209 th New Territories East Group Scout Troop 讀 練 理論 參 立臨 立 療 行 理 量 理 料 留 度 練 理 理 理 冷 練 理 力 理 不 不

untitled

untitled

公立學校教職員成績考核辦法修正草案總說明

untitled

untitled

「UPENN牙醫學院見習及費城文藝之旅」成果報告書

untitled

untitled

untitled

性別主流化簡介

untitled

untitled

untitled

Transcription:

1

MSDN Library MSDN Library 量 例 參 列 [ 說 ] [] [ 索 ] [] 來 MSDN Library 了 類 類 利 F1 http://msdn.microsoft.com/library/ http://msdn.microsoft.com/library/cht/

Object object 參 類 都 object 參 object Boxing 參 boxing ex object o = (int) 1; UnBoxing UnBoxing ex int i = (int) o;

ArrayList 類 (1) 列 列 不 便 ArrayList 料量 列 行 度 列不 不

ArrayList 類 (2) System.Collections; Count 數 數 Add Insert Remove Clear Sort Reverse

例 sample6-a1 (1) ArrayList 列 ArrayList class car public car(int x) id = x; public int id;

例 sample6-a1 (2) static void Main(string[] args) ArrayList myal = new ArrayList(); car mycar = new car(10); myal.add(12); myal.add("ives"); myal.add(mycar); Console.WriteLine("myAL[0] 1",0,myAL[0]); Console.WriteLine("myAL[0] 1",1,myAL[1]); Console.WriteLine("myAL[0] 1",2,((car)myAL[2]).id); ((car)myal[2]).id = 100; Console.WriteLine("myCar " + mycar.id);

練 sample6-b1 數 料 ( 不 數 ) 數 料 列 念 利 ArrayList 來 料 利 Sort 料 行

列類 Rank 列 度 Length 列 數 GetLength 度 度 Clone 列 列 ( 不 參 參 ) Sort 列 IndexOf 參數 索

例 sample6-a2 (1) 列類 參 class car public int id;

例 sample6-a2 (2) static void Main(string[] args) int[,] x = new int[2,3]; Console.WriteLine("Length " + x.length); Console.WriteLine("Rank " + x.rank); Console.WriteLine("GetLength(0) " + x.getlength(0)); Console.WriteLine("GetLength(1) " + x.getlength(1));

例 sample6-a2 (3) car[] mycar = new car[5]; for(int i=0; i<mycar.length; i++) mycar[i] = new car(); mycar[i].id = i; Console.WriteLine(); // 參 x[0,0] = 100; mycar[0].id = 100;

例 sample6-a2 (4) int[,] y = (int[,]) x.clone(); car[] mymoto = (car[]) mycar.clone(); y[0,0] = 0; mymoto[0].id = 0; Console.WriteLine("x[0,0] " + x[0,0]); Console.WriteLine("y[0,0] " + y[0,0]); Console.WriteLine("myCar[0].id " + mycar[0].id); Console.WriteLine("myMoto[0].id " + mymoto[0].id);

練 sample6-b2 立 int 列 10 1 ~ 10 數 (1~10) 列 數 列 索 念 利 IndexOf

串類 Length 串 數 ( 度 ) ToUpper / ToLower 串 Insert 串 PadLeft / PadRight 度 IndexOf 串 Split 串 切 串 列 Replace 串 SubString 串

例 sample6-a3 串類 string str = "Alice is a good student!!"; Console.WriteLine(str); Console.WriteLine("ToUpper " + str.toupper()); Console.WriteLine("ToLower " + str.tolower()); Console.WriteLine("ToLower " + str.insert(6,"wang ")) string[] strarray = str.split(' '); for(int i=0; i<strarray.length; i++) Console.WriteLine(strArray[i]);

練 sample6-b3 數 ( ) 列 數 念 利 Split 串 數

C c Console.WriteLine("0:c",4.5); //NT$4.50 數 Dn dn Console.WriteLine("0:d5",4); //00004 E e Console.WriteLine("0:e",4); //4.000000e+001 Fn fn Console.WriteLine("0:f3",4); //4.000 數 Nn nn Console.WriteLine("0:n2",4000); //4,000.00 六 X x Console.WriteLine("0:x",10); //a

數 串 0 數 數 數 料 0 數 # 數 數 數 料 數. 數 數 數 數 數 理, 數 1000 1000000 % 數 100

例 sample6-a4 (1) 數 串 double myvar1 = 0801234567; Console.WriteLine(" 1." + myvar1.tostring("(0##)###- ####")); int myvar2 = -12345; Console.WriteLine(" 2." + myvar2.tostring("######")); Console.WriteLine(" 3." + myvar2.tostring("000000"));

例 sample6-a4 (2) double myvar3 = -2.455; Console.WriteLine(" 4." + myvar3.tostring("#.##")); Console.WriteLine(" 5." + myvar3.tostring("00.00")); Console.WriteLine(" 6." + myvar3.tostring("00.00000")); double myvar4 = 1234567890; Console.WriteLine(" 7." + myvar4.tostring("#,#")); Console.WriteLine(" 8." + myvar4.tostring("#,")); Console.WriteLine(" 9." + myvar4.tostring("#,,")); Console.WriteLine("10." + myvar4.tostring("#,,,")); double myvar5 = 0.086; Console.WriteLine("11." + myvar5.tostring("#.#%"));

類 DateTime ( 年 ) Math 數 數 數 見數 數 Random 亂數

例 sample6-a5 DateTime Math 類 Console.WriteLine(" " + DateTime.Now); Console.WriteLine("2 10 " + Math.Pow(2,10)); Console.WriteLine("-2 " + Math.Abs(-2)); Console.WriteLine("Sin(pi/2) " + Math.Sin(Math.PI/2));

練 sample6-b4 年 列 年 年 念 利 DateTime 年 來

不 邏 邏 念 利 來 行 料 不 0 行 利 try catch 來

(1) 行 來 數 數 滑 滑

(2) 行 行行 行 數數 行 [ 行 ] 行 行 行 不 [ 不 ] 行 行 不 行

(3) 行 [] [] [ 數 ] [ 數 ] [ ] 來 數 數 行行 數 數 行 數 數

例 sample6-a6 數 x = 10; int c = 0; for(int i=0; i<10; i++) c+=i; c += x; ArrayList myal = new ArrayList(); myal.add(c); x = (int)myal[0];

例 理 (1) 行 讀 try catch finally 來 行 try catch 便 行 catch 理 不 catch 都 行 finally

例 理 (2) 例 類 都 Exception 例 類 例 類 類 Exception DivideByZeroException IndexOutOfRangeException InvalidCastException OverflowException 說 行 數 0 索 列 說 Message 例

例 理 (3) try ; catch ( 例 類 數 ) ; catch ( 例 類 數 ) ; finally ;

例 理 (4) try int x = 0; x = 3/x; catch Console.WriteLine("!!"); finally Console.WriteLine("");

例 sample6-a7 (1) 數 x 3 x try Console.Write(" 數 "); int x = int.parse(console.readline()); Console.WriteLine("" + (3/x));

例 sample6-a7 (2) catch Console.WriteLine("!!"); finally Console.WriteLine("");

練 sample6-b5 數 x x 串 列 念 例 理來 串

例 理 throw 來 throw 例 類 throw new 例 類 (); throw new Exception("error!!");

例 sample6-a8 (1) 例 static int getmonth() Console.Write(""); int month = int.parse(console.readline()); if(month > 12 month <= 0) throw new Exception(" 不!!"); else return month;

例 sample6-a8 (2) static void Main(string[] args) try Console.WriteLine("" + getmonth()); catch(exception e) Console.WriteLine(e.Message); finally Console.ReadLine();