C#判断字符串中的所有字符都一样 [英] C# determine if all characters in a string are the same
本文介绍了C#判断字符串中的所有字符都一样的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个情况我需要尝试并筛选出假的SSN号码。从我目前为止,如果他们是假的,他们都是一样的号码或123456789我可以过滤是最后一个,但有一个简单的方法来确定是否所有的字符都是相同见过?
I have a situation where I need to try and filter out fake SSN numbers. From what I've seen so far if they are fake they're all the same number or 123456789. I can filter for the last one, but is there an easy way to determine if all the characters are the same?
推荐答案
收益率(SSN。的鲜明的() .Count之间的()== 1)
return (ssn.Distinct().Count() == 1)
这篇关于C#判断字符串中的所有字符都一样的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文