首页 > 编程 > C# > 正文

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

2020-01-24 01:39:13
字体:
来源:转载
供稿:网友

本文实例讲述了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#程序设计有所帮助。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表