Thread: Classes(Sorry, but couldn't find it in search)

  1. #1
    Registered User
    Join Date
    Jun 2005
    Posts
    11

    Classes(Sorry, but couldn't find it in search)

    Hello, I'm sure this has been explained and explained. But I didn't see it for what I'm looking for. In C++, this is the normal class script

    class Goblin
    public:

    Goblin();
    ~Goblin();
    void SetGoblinHP(int):
    int GetGoblinHP();


    and then it's easily accessed by:

    Goblin gob;
    gob.SetGoblinHP(3).....etcetc


    So How Do I DO this in C#?

    Thanks
    Tim

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    Code:
    public class Goblin
    {
    	private int m_HP = 0;
    
    	public Goblin();
    	
    	public int HP
    	{
    		get { return m_HP: }
    		set { m_HP = value; }
    	}
    }
    HP now behaves like a public variable.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    11

    Classes

    Alright thanks! That works enough for me

    Tperry

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. search algorithm - making statistical decisions
    By Mario F. in forum C++ Programming
    Replies: 3
    Last Post: 11-18-2006, 10:03 AM
  2. Logical errors with seach function
    By Taka in forum C Programming
    Replies: 4
    Last Post: 09-18-2006, 05:20 AM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. Big help in Astar search code...
    By alvifarooq in forum C++ Programming
    Replies: 6
    Last Post: 09-24-2004, 11:38 AM
  5. Again Character Count, Word Count and String Search
    By client in forum C Programming
    Replies: 2
    Last Post: 05-09-2002, 11:40 AM