我在调用main函数时遇到了麻烦,因为它需要同时返回2个列表。该功能将卡从一个列表添加到另一个列表,然后将其从原始列表中删除。但是,当我尝试并调用我得到这个错误的函数...没有重载方法“命中”需要1个参数无过载方法“命中”需要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();
}
}
}
的问题是在这手牌类的命中功能底部
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;
}
}
}
为什么你需要退货?它们是引用(比如指针),所以你不需要返回它们,它们已经被修改了。 – tjameson 2013-03-18 01:57:09
要返回2个项目,通常会使用'Tuple',但是您的问题很难确定。 – 2013-03-18 02:08:22
正如你所看到的,我走出了自己的深度,我很抱歉发布这个,我会看看我能不能找出我出错的地方。 – 2013-03-18 02:18:39