static RelatedPosts()
{
Post.Saved += new EventHandler<SavedEventArgs>(Post_Saved);
}
static void Post_Saved(object sender, SavedEventArgs e)
{
if (e.Action == SaveAction.Update)
{
Post post = (Post)sender;
if (_Cache.ContainsKey(post.Id))
_Cache.Remove(post.Id);
}
}
I converted to:
Shared Sub New()
Post.Saved += New EventHandler(Of SavedEventArgs)(AddressOf Post_Saved)
End Sub
Private Shared Sub Post_Saved(ByVal sender As Object, ByVal e As SavedEventArgs)
If e.Action = SaveAction.Update Then
Dim post As Post = DirectCast(sender, Post)
If _Cache.ContainsKey(post.Id) Then
_Cache.Remove(post.Id)
End If
End If
End Sub
But it give me an error:
Public Shared event Saved() is an event and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.