如何让这个查询像在sql中一样工作?在sql中我可以在字符串上使用<和>运算符.
我一直在谷歌搜索大约20分钟,但还没有找到解决方案.
我无法将r.ExemptionCode转换为整数,因为它可能具有'91A,9AA,ZZZ,Z01'等值
from r in results
where (r.ExemptionCode > "900" || r.ExemptionCode == "701" || r.ExemptionCode == "702" || r.ExemptionCode == "721" || r.ExemptionCode == "724")
select r
Run Code Online (Sandbox Code Playgroud) //你好,我试图让我的代码工作我的比较如果字符串更大或小于10,但它无法正常工作.即使该值小于10,它也会写入10或更多.
int result = string1.CompareTo("10");
if (result < 0)
{
Console.WriteLine("less than 10");
}
else if (result >= 0)
{
Console.WriteLine("10 or more");
}
Run Code Online (Sandbox Code Playgroud) 我对 C# 很陌生,一直在寻找有关使用 Int32.Parse、Int32.TryParse、Convert.Int32 等将字符串转换为整数的解决方案。但是我找不到合适的解决方案来接近我想要的。我在这里找到了一个类似的帖子:运算符 '>=' 不能应用于 'string' 和 'string' 类型的操作数,但仍然找不到正确的解决方案。
这是我正在尝试编码的内容的简要说明。
打开名为“compare.xls”的 Excel 文件,读取文件并写入名为“tline.txt”的文本文件
然后打开文本文件“tline.txt”,逐行读取文本,只写入带有条件语句的名为“mkmatlab.txt”的文本文件。条件语句:如果从该行读取的数字为 25 <= x <= 50,则将其写入“mkmatlab.txt”(仅当它是整数时才写入文件)。
Excel文件中的内容的一个想法:
A1..| B1....... | C1........ | D1........| E1........|
0.1 |10.2000 |53.6000 |52.7894 |24.9608
0.2 |26.8209 |55.0851 |56.4726 |35.8431
0.3 |10.1009 |56.0314 |56.5013 |27.8922
0.4 |17.7008 |60.0054 |59.7650 |37.8018
Run Code Online (Sandbox Code Playgroud)
*符号 .. 和 | 只是在这里充当间距,Excel 文件或文本文件不包含任何这些符号。
说明:第一行包含 A1 到 E1。对于列 A1,包含 0.1 到 0.4,对于列 B1 到 E1,依此类推。
我在线上有评论
if (words1[t] >= 25 && words1[t] <= 50)
Run Code Online (Sandbox Code Playgroud)
我需要帮助的地方。
StreamReader fidin …Run Code Online (Sandbox Code Playgroud)