I encounter a error when I try to convert a string variable which is read from a text file to int. How can I convert the number that is read from a text to int?
namespace ConsoleApp1
{
class FileWriter
{
static void Main()
{
int a = 6;
StreamWriter writer = new StreamWriter(@"D:\asd.txt");
using (writer)
{
writer.WriteLine(a);
}
}
}
}
class FileReader
{
static void Second()
{
StreamReader reader = new StreamReader(@"D:\asd.txt");
using (reader)
{
string line = reader.ReadLine();
Console.WriteLine(line);
}
);
}
}