I am trying to understand events in C#.
I want to convert code from VB.NET to C# but I cannot succeed.
Can you please help me in converting the following code from VB.NET to C#?
I will appreciate your help.
Module Module1
Class PersonClass
Public Event nameChanged(ByVal aName As String)
Public _Name As String
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal value As String)
_Name = value
RaiseEvent nameChanged(value)
End Set
End Property
End Class
Dim WithEvents p As PersonClass
Sub Main()
p = New PersonClass
p.Name = "George"
Console.ReadLine()
End Sub
Sub p_nameChanged(ByVal aName As String) Handles p.nameChanged
Console.WriteLine("{0} name changed to : {1}", Date.Now.ToString("dd-MM-yy hh:mm:ss"), aName)
End Sub
End Module