Skip to content

Instantly share code, notes, and snippets.

@talyian
Created October 19, 2018 01:57
Show Gist options
  • Save talyian/126283db82949d0f5d423722a4b4220e to your computer and use it in GitHub Desktop.
Save talyian/126283db82949d0f5d423722a4b4220e to your computer and use it in GitHub Desktop.
Write some Ints to a File in C#
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