
Hi Martin,
I have CLR object of the following type
public partial class Response_Create_CustomerContact {
private string customerAccountD365Field;
private string sourceField;
private string customerNoNAVField;
private bool errorField;
private string errortextField;
/// <remarks/>
public string CustomerAccountD365 {
get {
return this.customerAccountD365Field;
}
set {
this.customerAccountD365Field = value;
}
}
/// <remarks/>
public string source {
get {
return this.sourceField;
}
set {
this.sourceField = value;
}
}
/// <remarks/>
public string CustomerNoNAV {
get {
return this.customerNoNAVField;
}
set {
this.customerNoNAVField = value;
}
}
/// <remarks/>
public bool Error {
get {
return this.errorField;
}
set {
this.errorField = value;
}
}
/// <remarks/>
public string Errortext {
get {
return this.errortextField;
}
set {
this.errortextField = value;
}
}
}
i'm getting array of type Response_Create_CustomerContact as a response
I'm not sure that how can i iterate in order to read the values in x++
Please always use Insert > Insert Code (in the rich formatting view) to paste source code. Isn't the following much nicer than what you posted?
public partial class Response_Create_CustomerContact
{
private string customerAccountD365Field;
private string sourceField;
private string customerNoNAVField;
private bool errorField;
private string errortextField;
///
public string CustomerAccountD365
{
get
{
return this.customerAccountD365Field;
}
set
{
this.customerAccountD365Field = value;
}
}
///
public string source
{
get
{
return this.sourceField;
}
set
{
this.sourceField = value;
}
}
///
public string CustomerNoNAV
{
get
{
return this.customerNoNAVField;
}
set
{
this.customerNoNAVField = value;
}
}
///
public bool Error
{
get
{
return this.errorField;
}
set
{
this.errorField = value;
}
}
///
public string Errortext
{
get
{
return this.errortextField;
}
set
{
this.errortextField = value;
}
}
}
It's off-topic, but you could make it much simpler:
public partial class Response_Create_CustomerContact
{
public string CustomerAccountD365 { get; set; }
public string Source { get; set; }
public string CustomerNoNAV { get; set; }
public bool Error { get; set; }
public string ErrorText { get; set; }
}
Anyway, if your question is how to iterate a collection, this class isn't really important.
What's the type of the object you want to iterate? Maybe Response_Create_CustomerContact[, List<Response_Create_CustomerContact>, ArrayList or something.
A solution that works in all these cases is using IEnumerable. Like this:
System.Collections.IEnumerable enumerable = aCollection;
System.Collections.IEnumerator enumerator = enumerable.GetEnumerator();
while (enumerator.MoveNext())
{
System.Object value = enumerator.get_Current();
}