Hi,
Arpan wrote:
The ASP.NET book that I am referring to learn ASP.NET says the
following:
----------------
If you don't provide a constructor that doesn't take any parameters,
you cannot do the following:
Dim mObject As New MyObject
----------------
Now isn't the above line (not the code line) wrong since ASP.NET
implicitly creates a no-argument constructor with the name "New" if a
class doesn't have a constructor? Hence the above code line is very
much valid, isn't it?
Please correct me if I am wrong.
Thanks,
Arpan
(Please allow me to write the example in C#, as I am not fluent in
VB.NET and wouldn't want to write wrong code)
That's only true if you don't provide *any* constructor. If you provide
a constructor with (for example)
public MyObject( string param1 )
{
// ...
}
then no empty constructor is created. Sometimes, as a developer, you
just don't want to allow empty constructors for your class.
HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering:
http://www.galasoft-LB.ch
Private/Malaysia:
http://mypage.bluewin.ch/lbugnion
Support children in Calcutta:
http://www.calcutta-espoir.ch