VB.NET'Like'操作符可能存在错误?

mcu*_*mcu 10 .net vb.net wildcard string-matching sql-like

为什么以下评估为True

Dim result = "b" Like "*a*b"
Run Code Online (Sandbox Code Playgroud)

谢谢.

编辑:
为了概括这一点,以下返回True:

"String1" Like "*AnyText1*AnyText2*AnyText???******????*String1"
Run Code Online (Sandbox Code Playgroud)

VBA正常工作,返回False.
PowerShell正常工作,返回False:

PS C:\Users\XXX> "b" -Like "*a*b"
False
Run Code Online (Sandbox Code Playgroud)

EDIT2:
错误报告的链接:https:
//connect.microsoft.com/VisualStudio/feedback/details/748415/a-bug-in-net-like-operator

Fre*_*dou 6

为了好玩,我决定打开ilspy来调试这个:-)

在这种方法;

    private static void MatchAsterisk(string Source, int SourceLength, int SourceIndex, LigatureInfo[] SourceLigatureInfo, string Pattern, int PatternLength, int PatternIndex, LigatureInfo[] PattternLigatureInfo, ref bool Mismatch, ref bool PatternError, CompareInfo Comparer, CompareOptions Options)
Run Code Online (Sandbox Code Playgroud)

对于这种情况

                if (SourceLength <= 0)
                {
                    return;
                }
Run Code Online (Sandbox Code Playgroud)

通过将其更改为

                if (SourceLength < 0)
                {
                    return;
                }
Run Code Online (Sandbox Code Playgroud)

它似乎使它按预期工作

我只做了一些小测试,没什么大不了的

问题是; 它只是看着最后的星号,当它有效时,就停在那里

我的小改动确保检查前一个,或事实上的任何事情

我的修复

 Dim result = "b" Like "*a*b"
 now return false

 "String1" Like "*AnyText1*AnyText2*AnyText???******????*String1"
 now return false
Run Code Online (Sandbox Code Playgroud)

但是当它需要返回true时返回true