Properties
Written by: maffelu , 2009-04-16 17:55:01
private int X;
public int setX(int y)
{
x = y;
}
public int getX()
{
return X;
}
public class myClass
{
private int X;
public int varX
{
get
{
return X;
}
set
{
X = value;
}
}
}
myClass mC = new myClass();
mC.varX = 4;
Console.WriteLine(mC.varX);
Console.Read();
public class Penn
{
private int height;
private string color;
public int PennHeight
{
get
{
return height;
}
set
{
height = value;
}
}
public string PennColor
{
get
{
return color;
}
set
{
color = value;
}
}
}
public static void Main(string[] args)
{
Penn bigBluePenn = new Penn();
Penn bigRedPenn = new Penn();
bigBluePenn.PennColor = "Blue";
bigBluePenn.PennHeight = 10;
bigRedPenn.PennColor = "Red";
bigRedPenn.PennHeight = 7;
Console.WriteLine("I have two pencils:");
Console.WriteLine("My first penn is {0} and its height is {1} cm", bigBluePenn.PennColor, bigBluePenn.PennHeight);
Console.WriteLine("My second penn is {0} and its height is {1} cm", bigRedPenn.PennColor, bigRedPenn.PennHeight);
Console.Read();
}
There are no comments on this article.
If you have any question or just want to leave a message, just fill out the form below!
Your e-mail will not be visible in your post, it is for validation reasons only
Maffelu
Creator and admin of MorkaLork.com.
Started programming in HTML back when frames and tables was the way to design a page, moved on to Pascal/Delphi, PHP, javascript/jQuery, VB.NET/C#, Java and C++.
Currently studies .NET (in general) focusing on ASP.NET.