111962
(YU.)
1
I have implemented the following logic, but I am still getting a null exception. How can I solve this? Thank you!!
If Condition:
String.IsNullOrEmpty(Queue_Test_Data_item(“LoanRate”).ToString) or String.IsNullOrWhiteSpace(Queue_Test_Data_item(“LoanRate”).ToString)
※Queue_Test_Data_item is a Dictionary type variable for storing items retrieved from the queue…
Hi
Pls try with this single expression itself
String.IsNullOrEmpty(Queue_Test_Data_item(“LoanRate”).ToString)
And make sure there is a field named LoanRate in that queue item
Cheers @111962
Yoichi
(Yoichi)
3
Hi,
Can you try the following expression?
Queue_Test_Data_item("LoanRate") is Nothing OrElse String.IsNullOrEmpty(Queue_Test_Data_item("LoanRate").ToString) OrElse String.IsNullOrWhiteSpace(Queue_Test_Data_item("LoanRate").ToString)
Or the following might be better.
(Not Queue_Test_Data_item.ContainsKey("LoanRate")) OrElse String.IsNullOrEmpty(Queue_Test_Data_item("LoanRate").ToString) OrElse String.IsNullOrWhiteSpace(Queue_Test_Data_item("LoanRate").ToString)
Regards,
1 Like
111962
(YU.)
4
Thank you for your quick reply.
I tried this, but still had the same error.
and I’m sure there is a field named LoanRate in the queue item.
111962
(YU.)
5
Thank you for your quick reply.
I tried the code below this one, and there was no error.
Queue_Test_Data_item("LoanRate") is Nothing OrElse String.IsNullOrEmpty(Queue_Test_Data_item("LoanRate").ToString) OrElse String.IsNullOrWhiteSpace(Queue_Test_Data_item("LoanRate").ToString)
But, When I tried this, I got the same null exception.
(Not Queue_Test_Data_item.ContainsKey("LoanRate")) OrElse String.IsNullOrEmpty(Queue_Test_Data_item("LoanRate").ToString) OrElse String.IsNullOrWhiteSpace(Queue_Test_Data_item("LoanRate").ToString)
I wasn’t quite sure what was causing the this, but I was able to resolve the error using the first method., thank you very much!!
1 Like
Yoichi
(Yoichi)
6
Hi,
Second code checks if key named “LoanRate” exists. As it seems the key exists In this case, the first one will be solution.
FYI: This expression uses OrElse operator. As it helps you in this case, see the following in detials.
Regards,
1 Like
111962
(YU.)
7
I see. Thank you for the reference.
1 Like