Evaluating an event - C# to VB.NET

C

Carlos Rodriguez

When evaluating if the Deactivated event Is Nothing. It cause an errorWhat
is the right translation from C# to VB.NET?C#public void Deactivate()
{
this.m_transactions.Clear();
if (this.Deactivated != null)
{
this.Deactivated(this, EventArgs.Empty);
}
}


VB.NETPublic Sub Deactivate()
Me.m_transactions.Clear
If (Not Me.Deactivated Is Nothing) Then
Me.Deactivated.Invoke(Me, EventArgs.Empty)
End If
End Sub
 
T

Tom Shelton

When evaluating if the Deactivated event Is Nothing. It cause an errorWhat
is the right translation from C# to VB.NET?C#public void Deactivate()
{
this.m_transactions.Clear();
if (this.Deactivated != null)
{
this.Deactivated(this, EventArgs.Empty);
}
}


VB.NETPublic Sub Deactivate()
Me.m_transactions.Clear
RaiseEvent Me.Deactivated (Me, EventArgs.Empty);

You don't need to do the check in VB, it will do it for you :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top