Add VB snippets

This commit is contained in:
Cristian Ambrosini 2023-07-18 14:52:24 +02:00 committed by Zsolt Kolbay
parent 9f0d07611e
commit d3f9afa35d
2 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,18 @@
[source,vbnet,diff-id=1,diff-type=compliant]
----
Private Sub MyMethod(ByVal items As List(Of MyObject))
For Each item In items
logger.Debug("Evaluating: {name} which is {availability}", item.Name, If(item.IsAvailable, "available", "not available"))
Try
If item.IsAvailable Then
' Do stuff
Else
' Do other stuff
End If
Catch ex As Exception
logger.Error(ex, "Ops! Something happened: ")
End Try
Next
End Sub
----

View File

@ -0,0 +1,22 @@
[source,vbnet,diff-id=1,diff-type=compliant]
----
Private Sub MyMethod(ByVal items As List(Of MyObject))
logger.Debug("The operation started")
For Each item In items
Try
If item.IsAvailable Then
' Do stuff
logger.Debug($"{item.Name} is available")
Else
logger.Debug($"{item.Name} is not available")
' Do other stuff
End If
Catch ex As Exception
logger.Error("Ops! Something happened")
logger.Error(ex.Message)
End Try
Next
logger.Debug("The operation ended")
End Sub
----