Dear Sir
I 'm trying convert c# to vb.net but I have an error : `Error BC33101 Type 'Regex' must be a value type or a type argument constrained to 'Structure' in order to be used with 'Nullable' or nullable modifier '?' in vb.net
Please Guide me.
Thanks
Code in c#
private readonly Regex? _regex;
Code in vb.net  error below line code
Private ReadOnly _regex? As Regex
 
public class StringMatcher
{
    private readonly string _pattern;
    private readonly Regex? _regex;
    public Func<string, bool> IsMatch;
    public StringMatcher(string pattern, StringMatchingMethod matchingMethod)
    {
        _pattern = pattern;
        switch (matchingMethod)
        {
            case StringMatchingMethod.StartsWith:
                IsMatch = StartsWith;
                break;
            case StringMatchingMethod.Contains:
                IsMatch = Contains;
                break;
            case StringMatchingMethod.Regex:
                try
                {
                    _regex = new Regex(pattern, RegexOptions.IgnoreCase);
                }
                catch
                {
                    _regex = null;
                }
                IsMatch = MatchesRegex;
                break;
            default:
                throw new ArgumentOutOfRangeException(nameof(matchingMethod), "Unknown string matching method");
        }
    }
}
public enum StringMatchingMethod
{
    StartsWith,
    Contains,
    Regex,
}
 Code in VB.NET
Public Class StringMatcher
    Private ReadOnly _pattern As String
    'Error below line code Type 'Regex' must be a value type or a type argument constrained to 'Structure' in order to be used with 'Nullable' or nullable modifier
    Private ReadOnly _regex? As Regex
    Public IsMatch As Func(Of String, Boolean)
    Public Sub New(ByVal pattern As String, ByVal matchingMethod As StringMatchingMethod)
        _pattern = pattern
        Select Case matchingMethod
            Case StringMatchingMethod.StartsWith
                IsMatch = AddressOf StartsWith
            Case StringMatchingMethod.Contains
                IsMatch = AddressOf Contains
            Case StringMatchingMethod.Regex
                Try
                    _regex = New Regex(pattern, RegexOptions.IgnoreCase)
                Catch
                    _regex = Nothing
                End Try
                IsMatch = AddressOf MatchesRegex
            Case Else
                Throw New ArgumentOutOfRangeException(NameOf(matchingMethod), "Unknown string matching method")
        End Select
    End Sub
End Class
Public Enum StringMatchingMethod
    StartsWith
    Contains
    Regex
End Enum