Skip to Content
.NET Windows® Forms Custom Controls
book

.NET Windows® Forms Custom Controls

by Richard Weeks
January 2002
Intermediate to advanced
288 pages
5h 48m
English
Sams
Content preview from .NET Windows® Forms Custom Controls

Properties

Properties are syntactic shorthand for accessor and mutator methods. In place of coding methods that retrieve or modify a particular member variable, properties provide both a get and a set submethod. Support for property style methods can be found in Visual Basic, C#, C++ (using __declspec()) and COM, to name a few. Consider the code snippet in Listing 2.2.

Listing 2.2. Get/Set Methods
 1: class Person {
 2:
 3:    private string name;
 4:
 5:    public void SetName( string Name ) {  name = Name; }
 6:    public string GetName( ) {  return name; }
 7: }
 8:
 9: Person me = new Person( );
10: me.SetName( "Richard" );
11:  Console.WriteLine( me.GetName( ) );

The code in Listing 2.2 shows two methods whose sole purpose is to expose the underlying private ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Pro .NET 5 Custom Libraries: Implementing Custom .NET Data Types

Pro .NET 5 Custom Libraries: Implementing Custom .NET Data Types

Roger Villela
Professional C# 5.0 and .NET 4.5.1

Professional C# 5.0 and .NET 4.5.1

Christian Nagel, Jay Glynn, Morgan Skinner

Publisher Resources

ISBN: 0672323338Purchase book