Click here to Skip to main content
15,891,943 members
Home / Discussions / C#
   

C#

 
GeneralRe: Multiple Forms Pin
moredip14-Apr-03 11:46
moredip14-Apr-03 11:46 
QuestionWhat's up with User Controls? Pin
Dave Kerr13-Apr-03 0:54
Dave Kerr13-Apr-03 0:54 
AnswerRe: What's up with User Controls? Pin
Danny Blanchard13-Apr-03 20:19
Danny Blanchard13-Apr-03 20:19 
AnswerRe: What's up with User Controls? Pin
Martin Cook15-Apr-03 8:33
professionalMartin Cook15-Apr-03 8:33 
GeneralOne more question on web services Pin
Cristoff13-Apr-03 0:47
Cristoff13-Apr-03 0:47 
GeneralRe: One more question on web services Pin
moredip13-Apr-03 2:49
moredip13-Apr-03 2:49 
GeneralA simple property question Pin
kensai12-Apr-03 23:57
kensai12-Apr-03 23:57 
GeneralRe: A simple property question Pin
Dave Kerr13-Apr-03 1:03
Dave Kerr13-Apr-03 1:03 
OK, if you had a class called, i don't know, Company, with the property you mentioned in it, then you could do this...

Company someCompany = new Company();

// do stuff with someCompany.

Customers someCompaniesCustomers = someCompany.Customers;

All it means is you have a property called 'Customers', which is of type 'Customers', and when you try to 'get' it (like i did in the example above) the 'get' block is executed, so in this case, it returns a new Customers object, initialsed with the company. It works the other way round too, if the source was this...

public Customers Customers
{
set
{
this.customers = value;
}
}

now you can do this...

sameCompany.Customers = someCustomers;

And the 'set' block is called. I've used 'this' to make it explicit that i'm setting a member variable, thats not actually needed, but it gets the idea across. The example you have is quite unusual however, normally the properties are much more simple, heres a better example.

public class Cat
{
protected string name;
protected string breed;
protected int age;

public int Age // Read only property, you can only 'get' it.
{
get{return age;}
}
public string Name // Read/Write property.
{
get {return name;}
set {name = value;}
}

}

this is more simple. If you've ever used C++, then they're a way of having accessors (GetAge, SetAge etc) which is more user friendly. You can do all sorts with properties, for example, if you make a user control, you can make things like the text color a property, and tell .NET to use a color selector to show the property, so more and more things can be set in design time. Have a read through the MSDN examples on properties, they're very exhaustive.

Dave Kerr
focus_business@hotmail.com
www.focus.esmartweb.com
GeneralRe: A simple property question Pin
kensai14-Apr-03 9:50
kensai14-Apr-03 9:50 
GeneralRe: A simple property question Pin
Anonymous23-Apr-03 10:02
Anonymous23-Apr-03 10:02 
GeneralListview and database Pin
fredza12-Apr-03 21:48
fredza12-Apr-03 21:48 
GeneralRe: Listview and database Pin
Stephane Rodriguez.12-Apr-03 22:11
Stephane Rodriguez.12-Apr-03 22:11 
Generaluint.Parse() vs. Convert.ToUint32() Pin
moredip12-Apr-03 14:48
moredip12-Apr-03 14:48 
GeneralRe: uint.Parse() vs. Convert.ToUint32() Pin
Stephane Rodriguez.12-Apr-03 21:10
Stephane Rodriguez.12-Apr-03 21:10 
GeneralRe: uint.Parse() vs. Convert.ToUint32() Pin
moredip13-Apr-03 0:38
moredip13-Apr-03 0:38 
GeneralRe: uint.Parse() vs. Convert.ToUint32() Pin
Stephane Rodriguez.13-Apr-03 1:15
Stephane Rodriguez.13-Apr-03 1:15 
GeneralRe: uint.Parse() vs. Convert.ToUint32() Pin
moredip13-Apr-03 1:23
moredip13-Apr-03 1:23 
GeneralRe: uint.Parse() vs. Convert.ToUint32() Pin
leppie13-Apr-03 3:00
leppie13-Apr-03 3:00 
GeneralRe: uint.Parse() vs. Convert.ToUint32() Pin
moredip13-Apr-03 3:01
moredip13-Apr-03 3:01 
GeneralTcpClient Problem Pin
Michal Januszczyk12-Apr-03 12:41
sussMichal Januszczyk12-Apr-03 12:41 
GeneralRe: TcpClient Problem Pin
Stephane Rodriguez.12-Apr-03 21:24
Stephane Rodriguez.12-Apr-03 21:24 
GeneralRe: TcpClient Problem Pin
Michal Januszczyk13-Apr-03 11:06
sussMichal Januszczyk13-Apr-03 11:06 
GeneralCharacter Codes Pin
J. Dunlap12-Apr-03 10:52
J. Dunlap12-Apr-03 10:52 
GeneralRe: Character Codes Pin
Stephane Rodriguez.12-Apr-03 21:08
Stephane Rodriguez.12-Apr-03 21:08 
Generalreading double encoded by php pack() problem Pin
Member 28242012-Apr-03 10:42
Member 28242012-Apr-03 10:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.