Question Locked

Methods and classes in C#

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi all, for a college assignment I have been asked to create a C# program with Microsoft visual studio, which mimicks a Tamagotchi. The program has to contain methods and classes. I have done loads of reading but just cant seem to get my head around methods! Can any one please elaborate for me or does some one have any tips for using methods?

Thanks in advance

2 replies

by tony hopkinson

A class is a set of related properties and methods.
In C# there's no such thing as a method by itself, everything is part of a class.

The point is the method is what the class does. e.g become happier or sadder, though it's hard to imagine anything sadder than a Tamaguchi...

So if you had a tamaguchi cat it could range from yowl to purr and a dog from whine to whuff, with maybe a bit of tail wagging thrown in.

A better example might be a class wholenumber
with a property called value
it's methods could be add, aubstract, multiply etc.

Data and operations

Hths

This discussion is closed to new replies.