In VB.Net, I can declare a variable in a function as Static, like this:
Function EncodeForXml(ByVal data As String) As String
Static badAmpersand As Regex = new Regex("&(?![a-zA-Z]{2,6};|#[0-9]{2,4};)")
data = badAmpersand.Replace(data, "&")
''// more processing
return data
End Function
Note that I need to use the keyword Static
, rather than Shared
, which is the normal way to express this in VB.Net. How can I do this in C#? I can't find its equivalent.