Here is my code below, how can I make the if return true as it currently skips over the if statement because of the string values has a space in it.
string instrucType = "FM";
string tenInstrucType = "FM ";
if (tenInstrucType.Equals(instrucType))
{
blLandlordContactNumberHeader.Visible = true;
lblLandlordContactNumber.Text = landlordData.LandlordContact.DefPhone;
lblLandlordEmailHeader.Visible = true;
lblLandlordEmail.Text = landlordData.LandlordContact.DefEmail;
}
Use the Trim function:
if (tenInstrucType.Trim().Equals(instrucType.Trim()))
This will only trim from the ends though. If there is a possibility of a space in the middle, use the Replace.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With