我正在学习 C#,我关注了一个成功使用我的 CSV 文件的网站,我可以正确查询该文件。
var productsNetherlands =
from p in products
where p.Country == "Netherlands"
select new { p.Name, p.LaunchDate, p.Price, p.Description };
在上面的代码中,我正在过滤“荷兰”。我的问题是如何在该部分使用变量而不是硬编码“荷兰”?
例如:
var productsNetherlands =
from p in products
where p.Country == s_variable
select new { p.Name, p.LaunchDate, p.Price, p.Description };
我的 s_variable 在哪里
string s_variable = "Netherlands";
错误显示“错误 4 当前上下文中不存在名称 's_variable'”