I am suffering a weird problem in C# 4.5.
I have this in my model:
private DataMatrix<T> _matrix;
public DataMatrix<T> Matrix
{
get { return _matrix; }
set { _matrix = value; }
}
And I have a property which uses this:
public object SingleElement
{
get
{
if (Matrix == null) return String.Empty;
if (Matrix.ColumnCount >= 1 && Matrix.RowCount >= 1)
{
return Matrix[0, 0];
}
return null;
}
}
When I run it, before calling SingleElement, the Matrix property is null. But it doesn't return String.Empty, it goes to the second if-statement.
That's my Immediate window says:

I'm a bit confused. What did I do wrong?
Matrixhave an overloaded==operator that fails to properly handle null?Matrixisnull? I kinda suspect that it is non-null.Matrixvariable.Matrixis null and==is incorrectly implemented,Matrixis not null andToString()returns null for some reason or some third option we haven't considered yet.