I'm new with unity and c#. I have a class with subclass as below. Now I want to add new data inside the list of friends.
[Serializable]
public class PlayerData
{
public string playerName;
public string playerId;
public Friend[] friends;
}
[Serializable]
public class Friend
{
public string playerName;
public string playerId;
}
I want to add new friend in the friend class list. Code I have tried till now.
public string AddFriends(string friendId)
{
PlayerData pd = playerDataDict[playerId];
Friend friend = new Friend();
friend.playerId = friendId;
pd.friends.Append(friend);
return "sdwsd";
}
Thank you