Answer the question
In order to leave comments, you need to log in
Error: "There is no argument matching the required formal parameter", what is the reason?
The first file contains the following code:
public class PlayerCons
{
protected Guid m_connectionId;
protected string m_playerName;
public Guid ConnectionId { get { return m_connectionId; } }
public string PlayerName { get { return m_playerName; } }
public PlayerCons(string _playerName, Guid _connectionId)
{
m_playerName = _playerName;
m_connectionId = _connectionId;
}
}
public static void Msg_ws(string message, SomeInterface connection,List<PlayerCons> Connects)
{
string[] splitMessage = message.Split(':');
switch (splitMessage[0])
{
case "MyName": SetName(splitMessage,Connects,connection); break;
}
public static void SetName(string[] splitMessage, List<PlayerCons> Connects, SomeInterface connection)
{
var Id = connection.Id;
string _name = splitMessage[1];
Connects.Add(new PlayerCons { _playerName = _name, _connectionId = Id });
//ошибки:
//PlayerCons не содержит определение для "_playerName"
//PlayerCons не содержит определение для "_connectionId"
//Отсутствует аргумент, соответствующий требуемому формальному параметру "_playerName" из "PlayerConnect.PlayerConnect(string, Guid)".
}
public static void Main(string[] args)
{
var m_playerCons = new List<PlayerCons>();
}
Answer the question
In order to leave comments, you need to log in
new PlayerCons( _name, Id)
or
new PlayerCons() {PlayerName = _name, ConnectionId = Id}
You have 1 constructor, with specified overload
add
public PlayerCons(){}
и
new PlayerCons { _playerName = _name, _connectionId = Id }
new PlayerCons( _name, Id)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question