Markdown Code Syntax highlighting (StackExchange)

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

On StackExchange sites, code snippets may provide optional syntax highlighting. On sites like Stack Overflow the default language is derived from the tags used in the associated question (if applicable). In addition, a code snippet's syntax highlighting language may also be defined by adding an HTML comment to the text body.

<!-- language: lang-vb -->

    Sub ShowVB()
    Dim i As Long
    For i = 1 To 2
        If i = 3 Then
            MsgBox "How did that happen?"
        End If
    Next
    End Sub

Such a comment will change the syntax highlighting language for all subsequent code snippets, which can be rather useful, especially when several languages are involved in one post.

The above will be rendered with Visual Basic highlighting as:

Sub ShowVB()
Dim i As Long
For i = 1 To 2
    If i = 3 Then
        MsgBox "How did that happen?"
    End If
Next
End Sub


Got any Markdown Question?