Hi,
When I extend a class, for the new class's parameter-less constructor, is
the :base() called implicitly?
And for overloaded constructor, is :this(), and in turn :base() always
implicitly called?
Thanks!
Ryan 3 1571
Ryan Liu wrote: Hi,
When I extend a class, for the new class's parameter-less constructor, is the :base() called implicitly?
yes
And for overloaded constructor, is :this(), and in turn :base() always implicitly called?
:this() isn't called, :base() is. If you want to call one overload of
the ctor from another, you've to specify :this(..) explicitly.
FB
--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
"Ryan Liu" <ad********@online.sh.cn> wrote: When I extend a class, for the new class's parameter-less constructor, is the :base() called implicitly?
Yes.
And for overloaded constructor, is :this(), and in turn :base() always implicitly called?
this() is not called, but base() is called, unless you explicitly call a
different base or this constructor.
You can test these yourself with a little Console.WriteLine and a couple
of test classes. That's the best way to find the answer to these kinds
of questions.
-- Barry
-- http://barrkel.blogspot.com/
Try the attachment.
chanmm
"Ryan Liu" <ad********@online.sh.cn> wrote in message
news:uv**************@TK2MSFTNGP03.phx.gbl... Hi,
When I extend a class, for the new class's parameter-less constructor, is the :base() called implicitly?
And for overloaded constructor, is :this(), and in turn :base() always implicitly called?
Thanks! Ryan
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jon Shemitz |
last post by:
How come I can write code like "if (L)" but NOT code like "if (L ==
true)" when L is a class with an implicit operator bool?
///////////
List L = new List();
public class List
{
private...
|
by: Aaron Queenan |
last post by:
ECMA 334 section 13.4.3 User-defined implicit conversions states that D, the
set of types from which user-defined conversion operators will be considered,
includes (among other things) the base...
|
by: Chad Z. Hower aka Kudzu |
last post by:
I have an implicit conversion set up in an assembly from a Stream to
something else. In C#, it works. In VB it does not.
Does VB support implicit conversions? And if so any idea why it would work...
|
by: jonpb |
last post by:
Hi, Is it possible to define a implicit operator from base to derived
types in C#?
I have a Point class and would like to derive a Vector class from it and
add a couple new vector related...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |