cfrank2000
Well-known member
- Joined
- Mar 6, 2021
- Messages
- 71
- Programming Experience
- Beginner
I try to read a text file in an object but I get error message that I don't understand please help me. I need to do this homework.
the error msg is
Severity Code Description Project File Line Suppression State
Error CS1955 Non-invocable member 'StreamReader' cannot be used like a method. metjelentes C:\Users\Dell\source\repos\metjelentes\metjelentes\Program.cs 21 Active
the error appears at the line using(...
the error msg is
Severity Code Description Project File Line Suppression State
Error CS1955 Non-invocable member 'StreamReader' cannot be used like a method. metjelentes C:\Users\Dell\source\repos\metjelentes\metjelentes\Program.cs 21 Active
the error appears at the line using(...
monthly weathercast:
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections.Generic;
namespace metjelentes
{
class adatok
{
public string telepules = " ";
public string ido = " ";
public string szeliranyes_erosseg = " ";
public int homerseklet = 0;
}
class beolvasas
{
public void beolvas()
{
string olvas = @"c:\Users\Public\textfiles\tavirathu13.txt";
using (StreamReader sr = StreamReader(olvas, Encoding.Default))
{
//StreamReader sr = new StreamReader(olvas, Encoding.Default);
List<adatok> lista = new List<adatok>();
while (!sr.EndOfStream)
{
string sor = sr.ReadLine();
string[] elemek = sor.Split(' ');
lista.Add(new adatok());
}
}
}
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}