I have following code:
public MapReader(string fName) {
FileName = fName;
}
public MapReader(){
Console.WriteLine("Input valid file name:");
string name = Console.ReadLine();
this(name);
}
Apparently this is Java approach, which is not working in C#. Is there any option which doesn’t need added method for initialization?
You can’t do this in C#. You will have to set the property in the other constructor.
Ideally, you should separate out the dependency on the console.