简体   繁体   English

c#我想知道字符串中的前3个字符是否是字母?

[英]c# I want to know if the first 3 characters in a string is letter?

I'm developing a license plate number recognition system. 我正在开发车牌号码识别系统。 The plate numbers in our county has a string length of 6-7. 我县的板块数字长度为6-7。 The first 2 or 3 character are letters and the rest are numbers. 前2或3个字符是字母,其余字符是数字。

I want to check when my system detect a object and recognize it then if the output has the format of 3 letters and followed by numbers. 我想检查我的系统何时检测到一个对象然后识别它,然后输出的格式为3个字母,后跟数字。

var input = "abc123";
var result = input.Take(3).All(char.IsLetter);

this will help a lot. 这将有很大帮助。 I suggest that you also do validation not to allow charactors like *&&$%$^@)&(& as this will break your application. Good Luck! 我建议你也做验证不允许像* && $%$ ^ @)和(因为这会打破你的应用程序等特征。祝你好运!

http://www.dotnetperls.com/substring http://www.dotnetperls.com/substring

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

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