我在調用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