I have a stringbuilder in VB
I like to check to see if it contains a value if so I like to do something:
If strMsg.Contains("<table>") Then
' strMsg = strMsg + "<br/><br/><br/>"
strMsg.Append("<br/><br/><br/>")
End If
I tried the above but said contains is not a member of System.Text.StringBuilder.
What can I use in place of Contains
Contains()is not among Stringbuilder’s methods. That said, you have a couple options…1.: Test your values on the way in and maintain a boolean flag for your append
<br>tags state.2.: Perform
ToString()and callContains()from the result:3.: Implement
IndexOf()and/orContains()yourself:Disclaimer: This hasn’t been tested for performance… and Michael Haren’s comment was directed at the
ToString()option.