确定字符串中的所有字符是否相同 [英] Determine if all characters in a string are the same

查看:48
本文介绍了确定字符串中的所有字符是否相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一种情况,我需要尝试过滤掉虚假的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。 Distinct() .Count()== 1)

return (ssn.Distinct().Count() == 1)

这篇关于确定字符串中的所有字符是否相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆