C# WCF-如何在请求中使用相同的名称创建多个元素

C# WCF-如何在请求中使用相同的名称创建多个元素,c#,xml,wcf,web,service,C#,Xml,Wcf,Web,Service,我需要实现web服务来在客户端创建请求。多个Esc元素应与其他不同元素处于同一级别。如果我使用list,它会在Escs下创建元素列表。感谢您的帮助 试试这个 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml; using System.Xml.Linq; namespace ConsoleApplication1 { class P

我需要实现web服务来在客户端创建请求。多个Esc元素应与其他不同元素处于同一级别。如果我使用list,它会在Escs下创建元素列表。感谢您的帮助

试试这个

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            XNamespace ns = "abc";
            XElement request = new XElement(ns + "Request", new object[] {
               new XElement(ns + "Cont"),
               new XElement(ns + "Lea"),
               new XElement(ns + "Deal"),
               new XElement(ns + "Esc"),
               new XElement(ns + "Esc"),
               new XElement(ns + "Esc"),
               new XElement(ns + "Esc"),
               new XElement(ns + "Esc"),
               new XElement(ns + "Part"),
               new XElement(ns + "Veh")
            });
        }
    }
}