欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

C#把整个文件内容读入字符串变量的方法

程序员文章站 2023-12-05 22:49:58
本文实例讲述了c#把整个文件内容读入字符串变量的方法。分享给大家供大家参考。具体实现方法如下: using system; namespace playinga...

本文实例讲述了c#把整个文件内容读入字符串变量的方法。分享给大家供大家参考。具体实现方法如下:

using system;
namespace playingaround {
 class readall {
  public static void main(string[] args) {
   string contents = system.io.file.readalltext(@"c:\t1");
   console.out.writeline("contents = " + contents);
  }
 }
}

希望本文所述对大家的c#程序设计有所帮助。