Click here to Skip to main content
15,888,733 members
Home / Discussions / C#
   

C#

 
AnswerRe: own == Operator and null Problem Pin
harold aptroot9-Jul-09 6:51
harold aptroot9-Jul-09 6:51 
GeneralRe: own == Operator and null Problem Pin
chrisx519-Jul-09 23:18
chrisx519-Jul-09 23:18 
GeneralRe: own == Operator and null Problem Pin
harold aptroot10-Jul-09 3:37
harold aptroot10-Jul-09 3:37 
AnswerRe: own == Operator and null Problem Pin
Blue_Boy9-Jul-09 6:53
Blue_Boy9-Jul-09 6:53 
GeneralRe: own == Operator and null Problem Pin
chrisx519-Jul-09 23:22
chrisx519-Jul-09 23:22 
AnswerRe: own == Operator and null Problem Pin
DaveyM699-Jul-09 7:37
professionalDaveyM699-Jul-09 7:37 
GeneralRe: own == Operator and null Problem Pin
chrisx519-Jul-09 23:24
chrisx519-Jul-09 23:24 
GeneralRe: own == Operator and null Problem Pin
DaveyM6910-Jul-09 4:26
professionalDaveyM6910-Jul-09 4:26 
I've just had another look at this. It seems that by converting your class instances to objects, you can do a null check. e.g.
public class Test
{
    private int internalValue;
    public Test(int value)
    {
        internalValue = value;
    }

    public static bool operator ==(Test test1, Test test2)
    {
        object o1 = test1;
        object o2 = test2;
        if (o1 == null || o2 == null)
            return (o1 == null && o2 == null);
        return test1.internalValue == test2.internalValue;
    }
    public static bool operator !=(Test test1, Test test2)
    {
        return !(test1 == test2);
    }
}


Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
Why are you using VB6? Do you hate yourself? (Christian Graus)

GeneralRe: own == Operator and null Problem Pin
chrisx5112-Jul-09 23:32
chrisx5112-Jul-09 23:32 
AnswerRe: own == Operator and null Problem Pin
Dave Kreskowiak9-Jul-09 7:55
mveDave Kreskowiak9-Jul-09 7:55 
GeneralRe: own == Operator and null Problem [modified] Pin
chrisx519-Jul-09 23:27
chrisx519-Jul-09 23:27 
QuestionXML to ObservableCollection Pin
VickyC#9-Jul-09 6:08
VickyC#9-Jul-09 6:08 
AnswerRe: XML to ObservableCollection Pin
Jeremy Likness9-Jul-09 6:45
professionalJeremy Likness9-Jul-09 6:45 
GeneralRe: XML to ObservableCollection Pin
VickyC#9-Jul-09 6:50
VickyC#9-Jul-09 6:50 
GeneralRe: XML to ObservableCollection Pin
VickyC#9-Jul-09 7:06
VickyC#9-Jul-09 7:06 
GeneralRe: XML to ObservableCollection Pin
Jeremy Likness9-Jul-09 7:14
professionalJeremy Likness9-Jul-09 7:14 
GeneralRe: XML to ObservableCollection Pin
VickyC#9-Jul-09 7:35
VickyC#9-Jul-09 7:35 
GeneralRe: XML to ObservableCollection Pin
VickyC#9-Jul-09 7:43
VickyC#9-Jul-09 7:43 
QuestionCross Domain Connection Error Pin
javab9-Jul-09 6:07
javab9-Jul-09 6:07 
QuestionPanel Issues Pin
aei_totten9-Jul-09 4:55
aei_totten9-Jul-09 4:55 
AnswerRe: Panel Issues Pin
Luc Pattyn9-Jul-09 9:26
sitebuilderLuc Pattyn9-Jul-09 9:26 
AnswerRe: Panel Issues Pin
aei_totten9-Jul-09 10:27
aei_totten9-Jul-09 10:27 
GeneralRe: Panel Issues Pin
aei_totten9-Jul-09 10:48
aei_totten9-Jul-09 10:48 
QuestionHow to convert html to image using webbrowser? Pin
jacekzorek9-Jul-09 4:45
jacekzorek9-Jul-09 4:45 
AnswerRe: How to convert html to image using webbrowser? Pin
Christian Graus9-Jul-09 4:53
protectorChristian Graus9-Jul-09 4:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.