Can't Figure Out Classes in C#

Reply Forum
Forum postSharpe @ 2011-10-13 01:17:56
ReplyReply to
I'm having a horrible time figuring out how to create and use classes in C#. I have some experience in Python, where flat out everything is incomparably simpler.

Here's a class I'm trying to make for a character in my game:\

namespace ConsoleApplication1
{
    class Character
    {
        private string name;
        private int strength, attack, hitPoints;

        public Character(string name, int strength, int attack, int hitPoints)
        {
            this.name = name;
            this.strength = strength;
            this.attack = attack;
            this.hitPoints = hitPoints;
        }

        public string Name
        {
            get { return name; }
            set { name = value; }
        }
    }
}

I don't understand the "get/set" part, or really anything else either.

I want the user to create his character, called player, which will assign those values to the character object.

Thanks for the help!

-Sharpe











© net-tutorials.com 2006 - 2012

MailContact net-tutorials.com