I was using the following:
!string.IsNullOrEmpty(Model.ProductID)
But now I need to also check that the string is not equal to "0000". What's the most easy way to do this check?
!string.IsNullOrEmpty(Model.ProductID) && Model.ProductID != "0000"
or write an extension method:
public static class StringExtensions
{
public static bool IsNullEmptyOrZeros(this string value)
{
return !string.IsNullOrEmpty(value) && value != "0000";
}
}
and then:
if (!Model.ProductID.IsNullEmptyOrZeros())
{
...
}
if(!string.isNullOrEmpty(Model.ProductID) && Model.ProductID != "0000")
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