Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 665453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:42:35+00:00 2026-05-13T23:42:35+00:00

This issue is somewhat related: Problem with Code Generated by XSD.EXE: Sequence of Elements

  • 0

This issue is somewhat related:
Problem with Code Generated by XSD.EXE: Sequence of Elements is Generated as an Array

Basically, I would rather work with an ArrayList in C# code then an array. I have a collection of errors, and I’m writing code to send back additional errors to the already existing collection of errors. Or if I find the first error, I have to instantiate this object, and set the first error of the array. I don’t want to deal with resizing a C# array. It seems like it would be much easier to just add to an ArrayList.

I think question I referenced above was sort of asking the same thing, but in my case, I do have a complex type, not a simple one.

My schema has a field called Status which contains this:

<xs:element minOccurs="0" name="Errors">
 <xs:complexType>
   <xs:sequence>
     <xs:element minOccurs="0" maxOccurs="unbounded" name="Error">
       <xs:complexType>
         <xs:sequence>
            <xs:element name="ErrorNumber"  type="xs:string" /> 
            <xs:element name="ErrorMessage" type="xs:string" /> 
         </xs:sequence>
       </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
</xs:element>

I use xsd.exe to generate a C# class.

I could have made “Error” a separate schema, and referenced it (schema create with BizTalk 2006/R2), if that would make any difference in the C# generated.

The generated C# class looks like this:

private StatusError[] errorsField;

[System.Xml.Serialization.XmlArrayAttribute(Form

= System.Xml.Schema.XmlSchemaForm.Unqualified)]
[System.Xml.Serialization.XmlArrayItemAttribute(“Error”,
Form =
System.Xml.Schema.XmlSchemaForm.Unqualified,
IsNullable = false)]
public StatusError[] Errors
{
get
{
return this.errorsField;
}
set
{
this.errorsField = value;
}
} }

[System.CodeDom.Compiler.GeneratedCodeAttribute(“xsd”,
“2.0.50727.1432”)]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute(“code”)]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType
= true, Namespace = “https://firstrepublic.com/EagleConnect/Status/“)]
public partial class StatusError {

private string errorNumberField;

private string errorMessageField;

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form

= System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string ErrorNumber
{
get
{
return this.errorNumberField;
}
set
{
this.errorNumberField = value;
}
}

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T23:42:35+00:00Added an answer on May 13, 2026 at 11:42 pm

    Well, I had to continue, so I used Array.Resize. Came up with a method to look at the array, if it’s not there add it, if it was there add to it, etc… An arrayList would have been easier and quicker.

     // Call the method 
        StatusError newErrorToAdd1 = new StatusError();
        newErrorToAdd1.ErrorNumber = "1112";
        newErrorToAdd1.ErrorMessage = "Demo error "; 
        transactionRequestOut = AddErrorToTransactionRequest(transactionRequestOut, newErrorToAdd1);
    
    
    
    public static TransactionRequest AddErrorToTransactionRequest(TransactionRequest transReq, StatusError newErr)
    {
            int intErrSubscript; 
    
            // If response is there use it, else add it 
            if (transReq.TransactionResponse == null)
            {
                TransactionResponse transactionResponse = new TransactionResponse();
                transReq.TransactionResponse = transactionResponse; 
            }
    
            // If response/errors are there, use them, else add them  
            if (transReq.TransactionResponse.Status == null)
            {
                Status status = new Status();
                transReq.TransactionResponse.Status = status; 
            }
            // If response/errors are there, use them, else add them  
            if (transReq.TransactionResponse.Status.Errors == null)
            {
                StatusError[] errors = new StatusError[1];
                errors[0] = new StatusError();
                intErrSubscript = 0;
                transReq.TransactionResponse.Status.Errors = errors;
            }
            else
            {
                int newArraySize = transReq.TransactionResponse.Status.Errors.Length + 1;
                intErrSubscript = newArraySize - 1;
                StatusError[] errors = transReq.TransactionResponse.Status.Errors;
                Array.Resize<StatusError> (ref errors,  newArraySize);
                transReq.TransactionResponse.Status.Errors = errors; 
            }
            transReq.TransactionResponse.Status.Errors[intErrSubscript] = newErr;
            return transReq; 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This questions is somewhat related to this question Prawn + Prawnto Issue . I've
somewhat related to: libxml2 from java yes, this question is rather long-winded - sorry.
I've never had this issue before, so I'm somewhat lost. I'm getting two different
Why does this issue a badmatch error? I can't figure out why this would
This problem is somewhat complicated and I'm in a little over my head. I
I'm at somewhat of a disagreement with a fellow colleague on this issue. First
This is somewhat complex issue with several questions. Feel free to answer only the
I realize this issue is somewhat trivial, but I'm interested in knowing the correct
This is a somewhat unusual problem. I'm presently working on an effort to automate
This is somewhat related to my previous question but I've realised that I needed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.