看板 C_Sharp 關於我們 聯絡資訊
※ 引述《GoalBased (Artificail Intelligence)》之銘言: : 大概是長這樣,細節有錯的話自己改, : 是說..現在的新手會開檔讀檔,會用類別,不會用function是怎麼回事= = 感謝幫忙,我試著改成這樣 private void button1_Click(object sender, EventArgs e) { System.IO.StreamReader file = new System.IO.StreamReader("file.txt"); string str = file.ReadLine(); if (str == "father") { ClassFather xxx = new ClassFather(); IamFunction(file, xxx); } else if (str == "son") { ClassSon xxx = new ClassSon(); IamFunction(file, xxx); } } private void IamFunction(System.IO.StreamReader file, ClassFather xxx) { xxx.strA = file.ReadLine(); xxx.strB = file.ReadLine(); } 似乎是可以了@@ -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 42.69.93.23 ※ 文章網址: http://www.ptt.cc/bbs/C_Sharp/M.1400394654.A.C27.html