question

mterui avatar image
0 Likes"
mterui asked

Using GetSellerTransactions, getting null objects

How do I deal with null objects when using GetSellerTransactionsResponse type? GetSellerTransactionsResponseType eBayResponse = _ebayService.GetSellerTransactions(eBayRequest); TransactionType[] objTransations = eBayResponse.TransactionArray; foreach (TransactionType objTrans in objTransations) { ShippingServiceOptionsType shipType = objTrans.ShippingServiceSelected; AmountType insType = shipType.ShippingInsuranceCost; shipType is null, so I am getting an error when I try to access the object. How can I return a zero in its place?
.NET
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
devanathan.developersupport@ebay.com avatar image
0 Likes"
devanathan.developersupport@ebay.com answered
Hello mterui, You need to check for null before accessing the object, like if (objTrans.ShippingServiceSelected != null) { // return actual value } else { // return 0 } Best Regards, Devanathan Sampath eBay Developer Support
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.