There are many ways to verify Chinese in C #, here are a few of them for reference, and the validation of regular expressions is not written here, there is a chance to make it up later.
Method One:
Private BOOLIschina (stringmsg) { stringtemp; for(inti =0; I < Msg. Length; i++) {Temp= Msg. Substring (I,1); byte[] Ser = encoding.getencoding ("gb2312"). GetBytes (temp); if(Ser. Length = =2) { return true; } } return false;}
Method Two:
Private BOOLCheckchina (stringinput) { intCode =0; intChfrom = Convert.ToInt32 ("4e00", -);//Range (0X4E00~0X9FFF) converted to int (chfrom~chend) intChend = Convert.ToInt32 ("9fff", -); for(inti =0; I < input. Length; i++) {Code= CHAR.CONVERTTOUTF32 (Input,1);//gets the character Unicode encoding at the index specified in string input if(Code >= chfrom && Code <=chend) { return true;//when code returns true within the Chinese range } } return false;}
Method Three:
Public BOOLISCHINA1 (stringCString) { BOOLBoolvalue =false; for(inti =0; i < cstring.length; i++) { if(Convert.ToInt32 (Convert.tochar (cstring.substring (i,1))) <convert.toint32 (Convert.tochar ( -)) {boolvalue=false; } Else { returnBoolvalue =true; } } returnBoolvalue;}
C # Validation Chinese