ukerandi
asked on
C# Function
Hi,
I need to the following code to custom function.Any idea appreciate
I need to the following code to custom function.Any idea appreciate
if (TxtPostcode.Text == null && string.IsNullOrWhiteSpace(TxtPostcode.Text))
{
validate = 1;
}
if (TxtDestinationName.Text == null && string.IsNullOrWhiteSpace(TxtDestinationName.Text))
{
validate = 1;
}
if (TxtDestinationDescription.Text == null && string.IsNullOrWhiteSpace(TxtDestinationDescription.Text))
{
validate = 1;
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@it_saige - You are returning int NOT boolean.
@Pawan,
I did not say that I was returning a boolean. The result of the IsNullOrWhiteSpace method is a boolean.
The preceeding examples were using a ternary operation to return a 1 or a 0 based upon that boolean result. I am stating that those examples could be simplified further by converting the boolean result of IsNullOrWhiteSpace to an integer.
-saige-
I did not say that I was returning a boolean. The result of the IsNullOrWhiteSpace method is a boolean.
The preceeding examples were using a ternary operation to return a 1 or a 0 based upon that boolean result. I am stating that those examples could be simplified further by converting the boolean result of IsNullOrWhiteSpace to an integer.
-saige-
Ohh that way .. cool :)
ASKER
Hi Guy,Thanks i understand the logic in the Function but
issue is i can't use if condition for 4 or 5 time.
Any other better way to validate this
int ValidatePostcode = validate(TxtPostcode.Text) ;
int ValidateDestinationName = validate(TxtDestinationNam e.Text);
int DestinationDescription = validate(TxtDestinationDes cription.T ext);
IF(ValidatePostcode=0)
{
}
IF(ValidateDestinationName =0)
{
}
IF(DestinationDescription= 0)
{
}
issue is i can't use if condition for 4 or 5 time.
Any other better way to validate this
int ValidatePostcode = validate(TxtPostcode.Text)
int ValidateDestinationName = validate(TxtDestinationNam
int DestinationDescription = validate(TxtDestinationDes
IF(ValidatePostcode=0)
{
}
IF(ValidateDestinationName
{
}
IF(DestinationDescription=
{
}
ASKER
I have wrote a program using array to validate.It's working fine.
then for each() loop help me to validate.
thanks Guy
then for each() loop help me to validate.
thanks Guy
ASKER
thax