Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6377945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:56:26+00:00 2026-05-25T01:56:26+00:00

I’m new to C# and going through an example in a book. The example

  • 0

I’m new to C# and going through an example in a book. The example is based on creating a card class, deck class and another CardClient project that runs the two classes.

I am getting errors on compiling. The first error is:

Inconsistent accessibility: property type ‘ConsoleApplication1.Card.Suit’ is less accessible than property ‘ConsoleApplication1.Card.suit’

  1. Not sure why I get that error or what that error is telling me. It seems to be telling me that the property suit is less accessible than the same property, suit. So not sure what is going there.

Next error:

The type or namespace name ‘Deck’ could not be found (are you missing a using directive or an assembly reference?)

  1. I included a new reference to the ConsoleApplication1, and I declared that I am using that namespace, but for some reason the CardClient does not see it.

The code for both are below:

namespace ConsoleApplication1
{
    class Card
    {
        public Suit suit
        {
            get
            {
                return suit;
            }
        }
        public  Rank rank { get; }

        enum Suit
        {
            HEART,
            SPADE,
            CLUB,
            DIAMOND
        }

        enum Rank
        {
            ACE,
            TWO,
            THREE,
            FOUR,
            FIVE,
            SIX,
            SEVEN,
            EIGHT,
            NINE,
            TEN,
            JACK,
            QUEEN,
            KING
        }

        private Card()
        {
        }

        public Card(Suit suit, Rank rank)
        {
            this.suit = suit;
            this.rank = rank;
        }

        public override string ToString() 
        {
            return suit + " of " + rank;
        }
    }

    class Deck
    {
        private Card[] cards;

        public Deck()
        {
            cards = new Card[52];
            for (int suitVal = 0; suitVal < 4; suitVal++)
            {
                for (int rankVal = 1; rankVal < 14; rankVal++)
                {
                    cards[suitVal * 13 + rankVal - 1] = new cards[(Suit)suitVal, (Rank)rankVal];
                }
            }
        }

        public Card GetCard(int cardLocation) 
        {
            if (cardLocation >= 0 && cardLocation <= 51) 
                return cards[cardLocation];
            else {
                throw (new System.ArgumentOutOfRangeException("cardLocation", cardLocation, "cardLocation must be between 0 and 51."));
            }
        }

        public void Shuffle() 
        {
            Card[] tempDeck = new Card[52];
            bool[] assigned = new bool[52];
            Random sourceGen = new Random();

            for (int i = 0; i < 52; i++)
            {
                int destCard = 0;
                bool foundCard = false;
                while (foundCard == false)
                {
                    destCard = sourceGen.Next(52);
                    if (assigned[destCard] == false)
                        foundCard = true;
                }
                assigned[destCard] = true;
                tempDeck[destCard] = cards[i];
            }
            tempDeck.CopyTo(cards, 0);
        }
    }
}

code for the CardClient:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ConsoleApplication1;

namespace CardClient
{
    class CardClient
    {
        static void Main(string[] args)
        {
            Deck myDeck = new Deck();
            myDeck.Shuffle();
            for (int i = 0; i < 52; i++)
            {
                Card tempCard = myDeck.GetCard(i);
                Console.Write(tempCard.ToString());
                if (i != 51)
                    Console.Write(", ");
                else
                    Console.WriteLine();
            }
            Console.ReadKey();
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:56:27+00:00Added an answer on May 25, 2026 at 1:56 am

    You have a public variable suit but the enum type of that variable is private, so basically you declare the variable to be public accessible but the type isn’t, which makes no sense.

    You have to declare the enum Suit as being public to solve this problem.

    Also you have to declare the classes Deck and Card as public, so that the CardClient
    in the other namespace can access it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported
I have a French site that I want to parse, but am running into
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
i got an object with contents of html markup in it, for example: string
I need a function that will clean a strings' special characters. I do NOT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.