小编use*_*048的帖子

是否应该在Struct中使用太多数据?

public struct Cache {
    public int babyGangters { get; set; }
    public int punks { get; set; }
    public int ogs { get; set; }
    public int mercs { get; set; }
    public int hsPushers { get; set; }
    public int collegeDealers { get; set; }
    public int drugLords { get; set; }
    public int streetHoes { get; set; }
    public int webcamGrls { get; set; }
    public int escort { get; set; }
    public int turns { get; set; …
Run Code Online (Sandbox Code Playgroud)

c#

2
推荐指数
2
解决办法
290
查看次数

在where子句上正则表达式?

我正在尝试匹配XML文件上的特定术语并保存结果.这是字符串上的XML文本:

<node1>
  <node2>
    <text>Goodbye</text>
  </node2>
  <node2>
    <text>Welcome James</text>
  </node2>
  <node2>
    <text>Welcome John</text>
  </node2>
  <node2>
    <text>See you later!</text>
  </node2>
</node1>
Run Code Online (Sandbox Code Playgroud)

我想使用linq来选择任何欢迎的文本.然而欢迎之后的名字(例如欢迎詹姆斯)可以改变.因此,我试图理解是否有一种简单的方法可以通过正则表达式选择具有任何欢迎名称的节点?

这是C#代码:

private static void Test(string stream)
{
  XDocument doc = XDocument.Parse(stream); //stream contains the xml written above
  var list = from hello in doc.Descendants("node2")
             where attacker.Element("text").Value == "Welcome .*"
             select attacker.Element("text").Value;

  foreach (var x in attackList)
    Console.WriteLine(x);
}
Run Code Online (Sandbox Code Playgroud)

c# linq where-clause

2
推荐指数
1
解决办法
904
查看次数

如何通过LINQ选择队列中最常出现的值?

我有一个队列.如何选择最常出现的值并通过LINQ表达式将其分配给int?

int number = (from i in queue
             group // ?
             select i).First();
Run Code Online (Sandbox Code Playgroud)

c# linq

2
推荐指数
1
解决办法
2724
查看次数

标签 统计

c# ×3

linq ×2

where-clause ×1