如果语言不同,则将字符串值转换为布尔值. [英] Convert string value into boolean in case of different language.
本文介绍了如果语言不同,则将字符串值转换为布尔值.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一些来自xml文件的字符串.我的字符串可能是对,也可能是假,但不是英语.
就像西班牙文一样,
falso = false,
verdadero = true,
有这么多的语言价值是可能的.如何将这些不同的语言信息转换为布尔值1/0?
在转换时,我掌握了对/错的语言信息.如何使用CultureInfo或其他方式将其转换为布尔值?
预先感谢.
Hi,
i have some string coming from xml file. my string could be true or false but not in english language.
it will be like in spanish,
falso = false,
verdadero= true,
there are so many language values can be possible. how can i convert such different language information into boolean 1/0 ?
at the time of conversion i have information of the language that true/false coming from. how can i use CultureInfo or something else to convert it into Boolean ?
Thanks in advance.
推荐答案
我可以想到两个选择:
1)要么使用某种Web服务来获取返回单词的英语转换值.
2)如果您知道该值所属的所有可能的语言,请创建KeyValuePair
的List
.键将包含返回的某种语言的单词,其值将是它的含义,即True/False.将返回的单词与列表进行比较,并获取相应的值.这种方法将更快.
希望这会有所帮助!
I can think of two options:
1) Either use some web service to get the English converted value of the returned word.
2) If you know all possible languages that the value will belong to, create aList
ofKeyValuePair
. Key will contain the word in some language that is returned and the value will be it''s meaning i.e True/False. Compare the returned word against the list and fetch the corresponding value. This approach will be much faster.
Hope this helps!
这篇关于如果语言不同,则将字符串值转换为布尔值.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文