Question

I noticed this Windows-added code in a legacy *.cs file (prior to the advent of partial classes which evicted suchlike from the code files; specifically, this is in an old Windows CE project):

private System.Windows.Forms.Label lblDescription;
public System.Windows.Forms.TextBox txtItemDollar;

Why would some controls be private and others public? It's not the type of control that's the difference, because I see both TextBoxes and Labels that are in some cases private and in others public.

That's kind of academic, I guess; the more pertinent question is: what impact or import do these controls have by having one visibility specifier or the other?

Was it helpful?

Solution

I can understand a private control on what's effectively a compound component. That's just you want to display something in label, but you don't want to provide the facility to mess with it, change the font, move it etc.

The public member, well that's just wrong. Someoojah.txtItemDollar.Dispose; or = null; If it didn't fall over in a big heap after that I'd be very surprised. It violates so many fundamental design principals, its not true.

Can't say I'm surprised though. Early .net suffered from a number of very poor implementations, probably had a sales deadline to meet.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top