小编ose*_*ert的帖子

XElement Nodes()和Elements()有什么区别?

文件说:


XContainer.Nodes Method()按文档顺序返回此元素或文档的子节点的集合.

备注请注意,内容不包含属性.在LINQ to XML中,属性不被视为树的节点.它们是与元素关联的名称/值对.

XContainer.Elements Method()按文档顺序返回此元素或文档的子元素的集合.


所以它看起来像Nodes()有一个限制,但那为什么它存在?使用节点()有任何可能的原因或优点吗?

.net c# xelement

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

警告 CS1998 这种异步方法缺少“等待”运算符,正确的静音方法是什么?

这是我的测试:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace asynktest
{
    class Program
    {
        static async Task Main(string[] args)
        {
            var t = Test1(true);
            await t; //throws InvalidOperationException here. correct
            t = Test1(false);
            await t; //throws NotImplementedException here. correct

            t = Test2(true); //throws InvalidOperationException here. wrong
            await t;
            t = Test2(false); //throws NotImplementedException here. wrong
            await t;

            t = Test3(true);
            await t; //throws InvalidOperationException here. correct
            t = Test3(false); //throws NotImplementedException here. wrong
            await t;

            t = …
Run Code Online (Sandbox Code Playgroud)

c# async-await

0
推荐指数
1
解决办法
323
查看次数

标签 统计

c# ×2

.net ×1

async-await ×1

xelement ×1