Saturday, April 26, 2025

C# OO - Read From and Write to a Text File

Program.cs

using System;
using System.IO;

namespace LearnCS
{
    class Program
    {        
        static void Main(string[] args)
        {
            string toFile = "I will be sent to external file";
            File.WriteAllText("external.txt", toFile);

            string fromFile = File.ReadAllText("external.txt");
            Console.WriteLine(fromFile);

            Console.ReadLine();
        }
    }
}

No comments:

Post a Comment

Learning PyOpenGL - 1 - 3D Rotating Line

import pygame from pygame.locals import * from OpenGL.GL import * from OpenGL.GLU import * import math # Initialize Pygame and OpenGL pyg...