-
-
Save talyian/126283db82949d0f5d423722a4b4220e to your computer and use it in GitHub Desktop.
Write some Ints to a File in C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
class Program { | |
static int Main() { | |
int X = 1, Y = 20, Z = 455; | |
var writer = new StreamWriter("save.txt"); | |
writer.WriteLine(X); | |
writer.WriteLine(Y); | |
writer.WriteLine(Z); | |
writer.Close(); | |
var reader = new StreamReader("save.txt"); | |
Console.WriteLine("Reading save.txt:"); | |
Console.WriteLine(int.Parse(reader.ReadLine())); | |
Console.WriteLine(int.Parse(reader.ReadLine())); | |
Console.WriteLine(int.Parse(reader.ReadLine())); | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment