Hi there...
In your first sample ur definining an object (variable) but not creating it.
You know it's "newed" cuz obj != null
Yes it's possible to pass null to a constructor... for example
using System;
class Test {
static void Main() {
MyClass x = new MyClass(null);
Console.WriteLine("MyClass::Member is " + ((object) (x.Member !=
null ? "Not null" : "Null")).ToString());
Console.ReadLine();
}
}
class MyClass {
private object m_member;
public object Member {
get {return m_member;}
}
public MyClass(object arg) {
m_member = arg;
}
}
Regards,
--
Angel J. Hernández M.
MCSD
"Fei Li" <Fe***@discussions.microsoft.com> escribió en el mensaje
news:DC**********************************@microsof t.com...
Hi,
Is null value for a class instance allowed in C#? for example:
MyClass obj = null;
If Not, how to initiate an instance with value 0? How to detect if an
instance is "newed" ? And how to pass a null value to a class constructor
whch has a object paramer can be 0?
In general, how C# handle a pointer with value 0;
Thanks