【问题标题】:Adding a File to my application to keep track of account details将文件添加到我的应用程序以跟踪帐户详细信息
【发布时间】:2015-09-24 14:27:23
【问题描述】:

如何将文件添加到我的银行应用程序?

【问题讨论】:

  • 你想让人们浏览这个代码转储????而是发布相关部分
  • 我没有看到您尝试保存帐户并将其读回的任何代码 - 您能否显示您尝试执行此操作的位 - 这似乎是您所要求的。跨度>
  • 现在,我正在使用列表。
  • 查看您的课程,我建议您阅读有关面向对象设计基础的视图内容?一个人是出纳员,一个帐户是一个人???

标签: c#


【解决方案1】:

一个简单的谷歌搜索应该会让你上路。使用以下搜索查询:C# Read and Write to a text file 为您提供如下结果:

How to read from and write to a text file by using Visual C# How to both read and write a file in C# - Stack Overflow c# - Easiest way to read from and write to files - Stack Overflow C# Using StreamWriter - Dot Net Perls

这应该让你开始。只是一个侧面说明,除非分配需要使用泛型,否则对于您正在尝试做的事情可能是过度的。

【讨论】:

    【解决方案2】:

    Cba 会检查您的代码,但如果您输入“使用 System.IO;”在顶部,下面的部分将起作用。

    private void Save(string file, string text)
    {
        File.WriteAllText(file,text);
    }
    

    这采用文件的路径(例如,“.txt”文件)。并保存给定的文本。我想你可以像这样连接每个帐户的所有信息。

    Person person; //example of an instance of "Person" class.
    string text = person.PersonName+" : "+person.Gender;//etc
    string filename = "C:/examplefilename.txt";
    Save(filename, text);
    

    显然,您会根据自己的用途调整“文本”的值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-25
      • 2016-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-13
      • 1970-01-01
      相关资源
      最近更新 更多