Reputation: 7620
What does the if
statement mean here?
Merchant merchant1 =new Merchant();
if(!merchant1.SaveMerchantDdetails(x, y, z))
{
lblError.txt = "some error info";
}
else
{
}
Upvotes: 1
Views: 649
Reputation: 9061
If you look in the Merchant class there will be a method something like
public bool SaveMerchantDdetails(var x, var y, var z)
{
bool isSaved = false;
// Save Merchant Details and check if the save worked, store whether it did in isSave
return isSaved;
}
So the code:
if(!merchant1.SaveMerchantDdetails(x, y, z))
is simply checking if the boolean return from the SaveMerchantDdetails method is true or false. If the return is false then the error is displayed.
Upvotes: 0
Reputation: 1039538
It means that if the SaveMerchantDdetails
method called on the merchant1
instance returns false
it will set an error value to an error label.
Upvotes: 20
Reputation: 11745
When the save action for MerchantDdetails
failes the method returns false
in this case an error is shown by setting the error text.
Upvotes: 4
Reputation: 3318
If you write the code like this, it is much clearer what is happening. To have a local variable is also better for debugging.
Merchant merchant1 =new Merchant();
bool sucess = merchant1.SaveMerchantDdetails(x, y, z);
if(sucess == false)
{
lblError.txt = "some error info";
}
So your code executes the method SaveMerchantDdetails
on a object of the type Merchant
. If it fails, a label (lbl would hint to that...) text is set to "some error info".
Upvotes: 4
Reputation: 1282
There is more to this. This simple IF statement is saying that if Merchant1 from SaveMerchantDdetails
is false, then output an error message (apparently generated by another function)
Upvotes: 0
Reputation: 137198
The method SaveMerchantDetails
gets called with the arguments x
, y
and z
. It does what ever it does and returns a boolean to indicate success or failure.
By testing !merchant1.SaveMerchantDetails(x, y, z)
the code is testing for the false
or error state.
Upvotes: 0
Reputation: 1174
The if statement is being used to determine whether the Boolean return value of the method merchant1.SaveMerchantDdetails();
is true or false.
In this case if the method returns false then a label's text property is updated with the string shown. If the method returns true then the else block will be run instead.
Upvotes: 0
Reputation: 269658
If the call to the SaveMerchantDetails
method returns false
-- presumably because the details couldn't be saved properly for some reason -- then set the txt
property of lblError
to "some error info"; otherwise execute whatever code is in the else
block.
Upvotes: 0
Reputation: 12861
if result of SaveMerchantDdetails not true then lblError.txt = "some error info";
Upvotes: 0
Reputation: 81831
Well I am not sure what exactly SaveMerchantDetails()
methods does but it might mean if merchant doesn't save x.y,z then do the following in braces...
Upvotes: 1