C# xml serialization remove jagged array element name

前端 未结 3 903
梦谈多话
梦谈多话 2021-01-15 02:10

I have the below classes:

public class MainRequest
{
    private Request _dataField;

    [XmlElementAttribute(\"Parameters\")]
    public Request Parameters         


        
3条回答
  •  说谎
    说谎 (楼主)
    2021-01-15 03:05

    Try something like

        [XmlIgnore]
        public Field[][] Batch
        {
            get
            {
                return _field;
            }
            set
            {
                _field = value;
            }
        }
        [XmlArrayItemAttribute("ParameterEntry", IsNullable = false)]
        public Field[] BatchEntry
        {
            get
            {
                List OneDimFields = new List();
                foreach(Field[] field in _field)
                {
                    OneDimFields.AddRange(field);
                }
                return OneDimFields.ToArray(); 
            }
        }
    

提交回复
热议问题