SoFunction
Updated on 2025-03-08

C# Method to read the entire file content into a string variable

This article example describes how C# reads the entire file content into a string variable. Share it for your reference. The specific implementation method is as follows:

using System;
namespace PlayingAround {
 class ReadAll {
  public static void Main(string[] args) {
   string contents = (@"C:\t1");
   ("contents = " + contents);
  }
 }
}

I hope this article will be helpful to everyone's C# programming.