🔒 Closed How to access declared variable from usercontrol to windows form

Status
Not open for further replies.

Xlayer

Elite
Nag declared ako ng variable sa usercontrol:

public string _subject {get; set;}

Paano ko kaya ma access yang _subject sa windows form ?
 
Since public yung property mo, accessible naman dapat sya outside of the user control class.
So example, kung ang instance ng user control mo is userControl1, pwede mo ma-access yung property easily by:

userControl1._subject

May suggestion lang ako sa naming mo ng variables para madali mong ma-manage ang code base mo. Camel case prefixed with underscore is suggested for private member fields. Kaya nakakalito yung _subject sa pangalan pa lang. Dapat Subject sya since public property sya.

Pascal case: namespaces, classes, methods, properties
Camel case: method parameters, local variables
Camel case prefixed with underscore: private fields

Example:

public class Person
{
private string _aPrivateStringField;

public string APublicStringProperty { get; set; }

public string AMethod(string aStringParameter)
{
var aLocalStringVariable = string.Empty;
}
}

Ayan, so naming palang alam mo na ang public and private or ano ang accesible o hind outside of the class.
 
Status
Not open for further replies.

About this Thread

  • 9
    Replies
  • 269
    Views
  • 3
    Participants
Last reply from:
forumguy

Online now

Members online
549
Guests online
833
Total visitors
1,382

Forum statistics

Threads
2,275,117
Posts
28,960,729
Members
1,233,600
Latest member
Emmanuel1011
Back
Top