检查一个字符是元音或长辅音? [英] Check if a character is a vowel or consonant?

查看:130
本文介绍了检查一个字符是元音或长辅音?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有检查一个字符是元音辅音或代码?有些东西,比如CHAR = IsVowel? ?或者需要硬代码



 案一:
案'E':
案我':
案'O':
案'U':
案'A':
案'E':
案'我':
案'O':
案'U':


解决方案

您可以这样做:

 字符C = ... 
布尔isVowel =aeiouAEIOU .IndexOf(三)> = 0;

或这样的:

 字符C = ... 
布尔isVowel =AEIOU.IndexOf(c.ToString(),StringComparison.InvariantCultureIgnoreCase)> = 0;



一旦你添加的东西像éèe̋ȅëêĕe̊æøи等,此字符串会长期做下去,但基本的解决方案是一样的。


Is there a code to check if a character is a vowel or consonant? Some thing like char = IsVowel? Or need to hard code?

case ‘a’:
case ‘e’:
case ‘i’:
case ‘o’:
case ‘u’:
case ‘A’:
case ‘E’:
case ‘I’:
case ‘O’:
case ‘U’:

解决方案

You could do this:

char c = ...
bool isVowel = "aeiouAEIOU".IndexOf(c) >= 0;

or this:

char c = ...
bool isVowel = "aeiou".IndexOf(c.ToString(), StringComparison.InvariantCultureIgnoreCase) >= 0;

Once you add international support for things like éèe̋ȅëêĕe̊æøи etc. this string will get long, but the basic solution is the same.

这篇关于检查一个字符是元音或长辅音?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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