Inheritance
[code=csharp]public class ClassName : InheritedClass
{
}
// Example
public class OptionsForm : System.Windows.Forms.Form
{
}[/code][code=vb]Public Class [i]ClassName[/i]
Inherits [i]InheritedClass[/i]
End Class
Example
Public Class MyForm
Inherits System.Windows.Forms.Form
End Class[/code]More information about Inheritance can be found in PlausiblyDamps tutorial Intro to Object Orientated Programming Part 2 - Simple Inheritance and Constructors
Properties
[code=csharp]private ObjectType localVariable
public ObjectType PropertyName
{
get { return localVariable; }
set { localVariable = value; }
}
// Example
private string _name;
public string Name
{
get { return _name; }
set { _name = value; }
}[/code][code=vb]
Dim [i]localVariable[/i] As [i]ObjectType[/i]
Public Property [i]localVariable[/i]() As [i]ObjectType[/i]
Get
Return [i]localVariable[/i]
End Get
Set(ByVal Value As String)
[i]localVariable[/i] = Value
End Set
End Property
Example
Dim _name As String
Public Property Name() As String
Get
Return _name
End Get
Set(ByVal Value As String)
_name = Value
End Set
End Property[/code]More information about Properties can be found in PlausiblyDamps tutorial Intro to Object Orientated Programming Part 2 - Properties
Constructors
[code=csharp]public class ClassName
{
public ClassName()
{
// this is the constructor without parameters
}
public ClassName(ObjectType variableName)
{
// an overloaded constructor accepting parameters
}
}
// example
public class Person
{
public Person()
{
// this is the constructor without parameters
}
public Person(string pName)
{
// an overloaded constructor accepting parameters
}
}[/code][code=vb]Public Class [i]ClassName[/i]
Public Sub New()
End Sub
Public Sub New(ByVal [i]variableName[/i]As [i]ObjectType[/i])
End Sub
End Class
Example
Public Class Person
Public Sub New()
End Sub
Public Sub New(ByVal name As String)
End Sub
End Class[/code]More information about Constructors can be found in PlausiblyDamps tutorial Intro to Object Orientated Programming Part 2 - Constructors