简体   繁体   English

C#通配符字符串比较

[英]c# wildcard string comparison

I probably got an easy question for you but I haven't got the answer yet. 我可能为您提出了一个简单的问题,但还没有答案。

what I want is: 我想要的是:

compare string1 with string2 , which I built via a code before (not essential for the question), and if the string2 is not essential, I use a wildcard to fit every string1 in string2 . string1与我之前通过代码构建的string2 (对于问题不是必需的)进行比较,如果string2不是必需的,则我使用通配符将string2中的每个string1放入。

what I tried is: 我试过的是:

string1= "whatever the case may be"
string2= "*"
LikeOperator.LikeString(string1, string2, Microsoft.VisualBasic.CompareMethod.Binary)

My wildcard is not working properly. 我的通配符无法正常工作。 it doesn't give a "true" back. 它并没有给“真实”的回报。 What am I doing wrong there? 我在那里做错了什么?

And the answer is: 答案是:

You can't use wildcards on NULL-values. 您不能在NULL值上使用通配符。 Workaround is, to write "" into the string if it is NULL. 解决方法是,如果为NULL,则将“”写入字符串。

Now it works the way I posted it right on top. 现在它以我将其发布在顶部的方式工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM