Hi everyone, what is the difference between !el.LookupParameter("Company").HasValue and el.LookupParameter("Company").ToString() != "" ?
foreach (Element el in _AllElements)
{
if (!el.LookupParameter("Company").HasValue || el.LookupParameter("Company").ToString() != "" )
{
//code1
}
}
Why if I have only !el.LookupParameter("Company").HasValue the debugger just skips the execution of code1 but if I have both conditions that's when it actually finds unfilled parameter "Company" and executes everything inside of if statement ?
Solved! Go to Solution.
Solved by sahin.ikbal. Go to Solution.
It works very similar to normal string of C#.
Difference between
String s=null;
and
String s= "";
@sahin.ikbal you are comparing "String s=null" and "!el.LookupParameter("Company").HasValue" ?
in that case the question now is what is the difference between
e.LookupParameter("Company") != null
and
!el.LookupParameter("Company").HasValue
Thank you!
e.LookupParameter("Company") != null
Here the whole parameter is null, this will only come once there is no such parameter.
But if the parameter value type is something nullable than that null is found by HasValue.
Parameter.HasValue should be renamed. It appears to indicate a state that only exists prior to a parameter being assigned it's first value i.e. false if never used (would like to know if there are any instances otherwise). I don't know if it was meant to work that way but it is the way it appears to work.
Probably it comes from exposing some unmanaged idea that we need to check pointer actually refers to something (even that something being nothing) i.e. memory allocated before using it.
So not of much use as far as I can tell and a bit dangerously named (depending on your personal philosophy of the meaning of nothing).
Can't find what you're looking for? Ask the community or share your knowledge.