Programming Tutorial: Classes Part 1

esse quam videri
Revision as of 19:13, 4 February 2009 by Jerbils (talk | contribs) (New page: Language: C# == Basics == Objects are not as complicated as you might think. You can almost think of them as mini-programs, because they have variables and methods, just like a program...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Language: C#

Basics

Objects are not as complicated as you might think. You can almost think of them as mini-programs, because they have variables and methods, just like a program. However, they are modular and can be applied to many different situations. One of the many advantages of an object is that it can be written in one place and used in many, like a function.


The best way to understand an object in code is by relating it to a object in real life. The classic example is a dog. Say we have a dog. Dogs have a name, age, and a weight. A possible object for this in a C# console application would be:

<csharp>class dog {

   public string name;
   public int age, weight;

}</csharp>