Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Everyone
In Windows forms a rectangle variable name is used in a "if Statement" and it returns a Boolean values as such:

if (someRectangle)
if (!someRectangle)


or a rectangle is nulled as such:

someRectangle = nullptr;


Would you please describe the following:
-What property of the rectangle we are evaluating in these if statements, is it if exist, enabled, initialized, nonempty or ...?
-What happens when a rectangle is set equal to nullptr? is it disabled or ...?
-What is the equivalent of these "if statements" and "rectangle=nullptr" in WPF (c#)?
Posted

1 solution

This test merely checks whether the rectangle refers to an object or not. It has no effect on any of the properties in the case that the object exists. This holds true in all the three situations you have asked about.
 
Share this answer
 
Comments
Member 8456258 17-May-12 20:49pm    
How do you check whether the rectangle refers to an object or not in C#. How do you cancel that pointer to the object in c#.
Richard MacCutchan 18-May-12 4:12am    
You already have it: if (someRectangle == null) .... If the reference is not null then it points to an object. Generally speaking you do not need to worry about cancelling it unless you make explicit calls to its dispose() method. In some cases you can protect your code from inadvertent references to non-existent objects by putting blocks of code within using {} blocks.
Member 8456258 18-May-12 10:19am    
Thanks!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900