hey i want to return my whole string array but the program wants me to specify one

public string CreateCards( string[] Cards)
        {
            Cards = new string[52];
            for (int a = 0; a <= 51; a++)
            {
                if (a <= 12)
                {
                    Cards[a] = "   Hjärter " + (a+1).ToString();
                }
                if (a > 12 && a <= 25)
                {
                    Cards[a] = "   Ruter " + (a-12).ToString();
                }
                if (a > 25 && a <= 38)
                {
                    Cards[a] = "   Spader " + (a-25).ToString();
                }
                if (a > 38)
                {
                    Cards[a] = "   Klöver " + (a-38).ToString();
                }
            }
            return Cards;  //i get wrong here saying i need to return an array and Cards[] wont work
            //because they expect a value
        }

i want to call this from another part of the program which you input a string array [52] and my method creates cards for it
Thank you for answers :)

public string[] CreateCards( string[] Cards)
        {
            Cards = new string[52];
            for (int a = 0; a <= 51; a++)
            {
                if (a <= 12)
                {
                    Cards[a] = "   Hjärter " + (a+1).ToString();
                }
                if (a > 12 && a <= 25)
                {
                    Cards[a] = "   Ruter " + (a-12).ToString();
                }
                if (a > 25 && a <= 38)
                {
                    Cards[a] = "   Spader " + (a-25).ToString();
                }
                if (a > 38)
                {
                    Cards[a] = "   Klöver " + (a-38).ToString();
                }
            }
            return Cards;  //i get wrong here saying i need to return an array and Cards[] wont work
            //because they expect a value
        }

Need to add [] to the return in method declaration to make it an array.

But if i just leave it like Return Cards[];
i get an error saying "syntax error value expected"

Nono, look at the first line of my code block, that is where the brackets go.

public string[] CreateCards()

aha thank you so much! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.