[Solved] How to get ReadLine and then transfer the input to a variable


If you have just a constructor for player taking name as parameter, you could do

Console.WriteLine("Welcome to BattleShips. What is your name?");
Player player1 = new Player(System.Console.ReadLine());

if you have an empty ctor :

Player player1 = new Player();
Console.WriteLine("Welcome to BattleShips. What is your name?");
var name = System.Console.ReadLine();
player1.Name = name;

2

solved How to get ReadLine and then transfer the input to a variable