错误CS1501:没有重载方法' NewDeck'需要' 0 & # 39;参数(CS1501)

本文关键字:CS1501 参数 需要 NewDeck 重载 方法 错误 | 更新日期: 2023-09-27 18:04:14

我正在尝试创建一个将创建一组卡片的函数这可以随机输入到一个列表中,但尽管研究了解决方案调用my时,我不知道需要在括号中放置什么函数,当我返回它的变量。

using System;
using System.Collections.Generic;
using System.Text;
namespace BlackJackGameX
{
    public class Deck
    {
        Random rNumber = new Random();
        List<Card> Cards;
        List<Card> ShuffledDeck;
        public int iValue1 = 11;
        public int iValue2 = 2;
        public int iValue3 = 3;
        public int iValue4 = 4;
        public int iValue5 = 5;
        public int iValue6 = 6;
        public int iValue7 = 7;
        public int iValue8 = 8;
        public int iValue9 = 9;
        public int iValue10 = 10;
        public int iValue11 = 10;
        public int iValue12 = 10;
        public int iValue13 = 10;

我不知道NewDeck括号里该放些什么。

        public Deck()
        {
            Cards = NewDeck();
        }
        public void Shuffle()
        {
            for (int i = 0; i <= 51; ++i) 
            {
                int c = rNumber.Next (1, 53);
                ShuffledDeck.Add(Cards[c]);
            }
        }
        private List<Card> NewDeck(Suit CardSuit, FaceValue CardValue, int iValue)
        {
            var AllSuits = new Suit[]
            {
                Suit.Spades,
                Suit.Hearts,
                Suit.Clubs,
                Suit.Diamonds
            };
            var AllFaces = new FaceValue[]
            {
                FaceValue.Ace,
                FaceValue.Two,
                FaceValue.Three,
                FaceValue.Four,
                FaceValue.Five,
                FaceValue.Six,
                FaceValue.Seven,
                FaceValue.Eight,
                FaceValue.Nine,
                FaceValue.Ten,
                FaceValue.Jack,
                FaceValue.Queen,
                FaceValue.King
            };
            var AllValues = new int[]
            {
                iValue1,
                iValue2,
                iValue3,
                iValue4,
                iValue5,
                iValue6,
                iValue7,
                iValue8,
                iValue9,
                iValue10,
                iValue11,
                iValue12,
                iValue13
            };
            for (int i = 0; i <= 3; i++) 
            {
                for (int j = 0; j <= 12; j++) 
                {
                    Card newCard = new Card(AllSuits[i], AllFaces[j], AllValues[j]);
                }
            }

我不知道我需要在NewDeck括号里放些什么

            return NewDeck ();
        }
        public void Print()
        {
            Console.WriteLine(ShuffledDeck[1].CardValue);
            Console.ReadLine();
        }
    }
}

错误CS1501:没有重载方法' NewDeck'需要' 0 & # 39;参数(CS1501)

因为所讨论的方法的签名是:

private List<Card> NewDeck(Suit CardSuit, FaceValue CardValue, int iValue)

则需要传入如下值:

return NewDeck(Suit.Spades, FaceValue.Ace, iValue1);

正如Oren所说,在NewDeck方法中不使用这些值。拥有这样的签名也应该是OK的:

private List<Card> NewDeck()