⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usedclass.cs

📁 C#通过读取.txt文档进行运行的小系统
💻 CS
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -