我在 main 中调用类函数时遇到了麻烦,因为它需要同时返回 2 个列表。该函数将一张卡片从一个列表添加到另一个列表,然后将其从原始列表中删除。但是当我尝试调用该函数时,我得到了这个错误......没有重载方法“Hit”需要1个参数
using System;
using System.Collections.Generic;
using System.Text;
namespace BlackJackGameX
{
public class MainClass
{
public static void Main (string[] args)
{
Deck Cards = new Deck();
Hand PlayerHand = new Hand ();
Console.WriteLine("Welcome to Black Jack\n\nPress Enter To Start");
Console.ReadLine ();
PlayerHand.Hit(PlayerHand);
PlayerHand.Hit(PlayerHand);
PlayerHand.HandPrint();
}
}
}
问题出在这个手类的 Hit Function 的底部
using System;
using System.Collections.Generic;
using System.Text;
namespace BlackJackGameX
{
public class Hand
{
Deck CardDeck = new Deck ();
public List<Card> PlayerHand;
public Hand ()
{
}
public void HandPrint()
{
for (int i = 0; i < PlayerHand.Count; ++i)
{
Console.WriteLine("You have a " + PlayerHand[i].CardValue + " of " + PlayerHand[i].CardSuit);
if (i < PlayerHand.Count)
{
Console.WriteLine ("&");
}
}
Console.ReadLine();
}
public List<Card> Hit(List<Card> CardDeck, List<Card> PlayerHand)
{
PlayerHand.Add(CardDeck[1]);
CardDeck.Remove(CardDeck[1]);
return PlayerHand;
}
}
}