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; }

Edited 5 Years Ago by balrogf: n/a

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;
        }
This article has been dead for over six months. Start a new discussion instead.