Chào bạn
đây là code nhập xuất so nguyên đơn giản:
bạn để ý using System.IO;
Mã nguồn PHP:
using System;using System.Collections.Generic;using System.Text;using System.IO;namespace songuyen{ class so { private int soa; public int SoA { get { return soa; } set { soa = value; } } public so(int s) { soa = s; } public string DoiThanhChuoi() { string s = SoA.ToString(); return s; } } class qlso { List<so> ss; public qlso() { ss = new List<so>(); } public void GhiRaFile(string part) { StreamWriter w = new StreamWriter(part); for (int i = 0; i < ss.Count; i++) { w.WriteLine(ss[i].DoiThanhChuoi()); } w.Close(); } public void DocFile(string part) { StreamReader r = new StreamReader(part); string line = r.ReadLine(); while (line != null) { so x = new so(int.Parse(line)); ss.Add(x); line = r.ReadLine(); } } public void Nhap() { Console.WriteLine("nhap vao so"); int sg = int.Parse(Console.ReadLine()); so c = new so(sg); ss.Add(c); } public void XuatDS() { int n = ss.Count; for (int i = 0; i < n; i++) { Console.WriteLine(ss[i].DoiThanhChuoi()); } } } class ok { static void Main(string[] args) { qlso a = new qlso(); string part = "ok.txt"; int chon; nhaplai: Console.WriteLine("......................................................................"); Console.WriteLine("1-nhap, xuat va luu"); Console.WriteLine("2-doc"); Console.WriteLine("3-thoat"); Console.WriteLine("......................................................................"); chon = int.Parse(Console.ReadLine()); if (chon == 1) { a.Nhap(); a.XuatDS(); a.GhiRaFile(part); } else if (chon == 2) { qlso b = new qlso(); b.DocFile(part); b.XuatDS(); } goto nhaplai; } }}
Thông qua phân tích dữ liệu Google từ 86 quốc gia, mới đây, một công ty tại Anh đã công bố bảng xếp hạng kích tấc "cậu nhỏ" của các nước trên thế giới. Kết quả, hầu hết các nước xếp ở nhóm đầu của...
"Chim" của chàng trai Việt thuộc...