🔒 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
  • 287
    Views
  • 3
    Participants
Last reply from:
forumguy

Trending Topics

Online now

Members online
440
Guests online
1,503
Total visitors
1,943

Forum statistics

Threads
2,295,346
Posts
29,097,365
Members
1,206,819
Latest member
turdy666
Back
Top