I have finished a project of mine in c# 2008. but now i need to redo it again to c# 2005 to create an installer(setup and deployment) but i realized that there's no .count method in c# 2005. Please show me the proper conversion of the code below(error is : int cardCount = draw.Count(card => card.StartsWith(value) it's a poker program btw

string[] values = { "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A" };
            string[] suits = { "♠", "♦", "♣", "♥" };

            string[] draw = { "A ♠", "A ♦", "K ♦", "K ♥", "A ♥" };

            Boolean threeOf = false;
            Boolean twoOf = false;
            Boolean fullHouse = false;

            // full house, 3 cards of one value, 2 cards of another value
            foreach (string value in values)
            {
                int cardCount = draw.Count(card => card.StartsWith(value));
                if (cardCount == 3)
                { threeOf = true; }
               
                if (cardCount == 2)
                { twoOf = true; }
            }

            if (threeOf && twoOf)
            { fullHouse = true; }
static void Main(string[] args)
        {
            string[] values = { "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A" };
            string[] suits = { "♠", "♦", "♣", "♥" };

            string[] draw = { "A ♠", "A ♦", "K ♦", "K ♥", "A ♥" };

            Boolean threeOf = false;
            Boolean twoOf = false;
            Boolean fullHouse = false;

            // full house, 3 cards of one value, 2 cards of another value
            foreach (string value in values)
            {
               //int cardCount = draw.Count(card => card.StartsWith(value));
                int cardCount = Count(draw, value);
                 
                if (cardCount == 3)
                { threeOf = true; }

                if (cardCount == 2)
                { twoOf = true; }
            }

            if (threeOf && twoOf)
            { fullHouse = true; }
        }

static int Count(Array ar, string v)
        {
            int c=0;
            foreach (string ele in ar)
            {
                if (ele.StartsWith(v))
                    c++;
            }
            return c;
        }

thanks a lot

No problem, glad I could help. Please mark this thread as solved.

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.