usedclass.cs
来自「C#通过读取.txt文档进行运行的小系统」· CS 代码 · 共 73 行
CS
73 行
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Serialization;
using System.IO;
namespace BikeRentSystem
{
[Serializable]
public class UsedClass
{
public int lie;
public int mountain;
public int run;
public int collapse;
public int doubles;
public UsedClass()
{
lie=0;
mountain=0;
run=0;
collapse=0;
doubles=0;
}
//获取剩余车辆数目
public int[] GetUsedNum()
{
int[] result ={ 0, 0, 0, 0, 0 };
using (StreamReader sw = new StreamReader("used.txt"))
{
// Add some text to the file.
for (int i = 0; i < 5; i++)
{
result[i]=Int32.Parse(sw.ReadLine());
}
sw.Close();
}
return result;
}
//设置剩余车辆数目
public void SetUsedNum(int[] temp)
{
using (StreamWriter sw = new StreamWriter("used.txt"))
{
// Add some text to the file.
for(int i=0;i<temp.Length;i++)
{
sw.WriteLine(temp[i]+"");
}
sw.Close();
}
}
public UsedClass(int[] temp)
{
lie=temp[0];
mountain=temp[1];
run=temp[2];
collapse=temp[3];
doubles=temp[4];
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?