Hi everyone, I have some questions in C#
what are the differences between null comparisons null == value and value == null (value is a variable of any kind: int, string, float,...)
I heard that using prefix increment ++i instead of i++ in some case will enhance the program performance. Why is it so?
I have a snippet code as follow:
private int _number; public int Number { get { return _number} set { _number = value} }
public double Test { get { if (null == Number) return 1.1; else return 2.2; } }
the question is why here we use null == Number but not null == _number or Number == null or _number == null
4. if I have a struct as follow:
public struct Vector
{
public double X;
public double Y;
public Vector(double x, double y)
{
X = x;
Y = y;
}
}
public class Test
{
public Vector Position;
public void StructLength(Test t2)
{
Vector v = this.Position - t2.Position;
if (v.Length > 10)
return false;
}
}
if we subtract 2 struct likes above, what will be return? and the Length properties of struct will return what?
Is anyone willing to enlighten me? Thank in advance