473,406 Members | 2,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

implicit called base() or this()

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
Jun 19 '06 #1
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#)
------------------------------------------------------------------------
Jun 19 '06 #2
"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/
Jun 19 '06 #3
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



Jun 19 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
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...
0
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...
36
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...
8
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
tracyyun
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...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.