Consts and extension methods

If you’ve ever run into a case where you needed to do something like

Const htmltag = "<br></br>"

If htmltag.Length >= 0 Then
    // do some work
end if    

You can sometimes run into a compiler error: “There is more than one method with this name…”

The trick ?
Define the const with a specific type so the extension methods work

Const htmltag as string= "<br></br>"

If htmltag.Length >= 0 Then
    // do some work
end if    
4 Likes