473,320 Members | 1,945 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,320 software developers and data experts.

C# questions about basic constructs

.... I am coming off c++, so here is the list of question, I'd like to
get clarifications.

1. What's and the point of static constructor?

2. Why C# differs as to base class visibility in regard to Derived
class. In other words, Base class should be at least visible/
accessible as derived.

3. Can we member hiding by re-implementing the method in the derived
class with the same name but different signature and thus hiding the
base member. Here is the illustration:

public class A
{
public foo() {}

}

public class B
{
public foo(int i){}
}
4. Can we pass any type to indexer or only ints?

5.Can a member of a base lass be sealed, and not the whole class, thus
preventing a derived classes overriding it?

Sep 30 '08 #1
3 1202
1: to initialize static fields / run any other logic that applies to
the type rather than any single instance

3: that doesn't hide the original; it adds an overload. You can hide
the original by re-declaring with the same signature (and ideally, the
"new" modifier), but the original is still available by casting to the
base type.

4: any type

5: yes

Marc
Sep 30 '08 #2
On Mon, 29 Sep 2008 20:10:57 -0700, puzzlecracker <ir*********@gmail.com>
wrote:
[...]
2. Why C# differs as to base class visibility in regard to Derived
class. In other words, Base class should be at least visible/
accessible as derived. [...]
"Differs"? From what? In what respect? And why would it make sense to
not require the base class to be at least as accessible as the derived
class? How could any other code that doesn't have access to the base
class be able to use the derived class?

I'm not sure I understand the question, and Marc skipped right over it so
maybe he didn't either. If you can clarify what you mean, it might be
possible to provide an answer.

Pete
Sep 30 '08 #3
I'm not sure I understand the question, and Marc skipped right over it
so maybe he didn't either.
Correct; I meant to say, but forgot...

Marc
Sep 30 '08 #4

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

Similar topics

2
by: UNIXNewBie | last post by:
Please excuse the basic nature of these questions - I'm just starting off. This example is taken from Oracle PL/SQL 101 - Osborne/McGraw-Hill - ISBN 0-07-212606-X - page 314 Numbers to the...
3
by: Gonçalo Rodrigues | last post by:
Hi all, I've got two somewhat general questions related to exception handling in C++. My usual programming language is the lovely and flexible Python, but for various reasons, including the need...
17
by: William L. Bahn | last post by:
=========== (N869, p8) An object is a region of data storage in the execution environment, the contents of which can represent values. When explaining this to students, is it reasonable to say...
4
by: AzizMandar | last post by:
C++ Event Coding Questions I have done some simple programs in C++ and read a lot of good C++ books (Including The C++ Programing Language, and C++ Primer) I am trying to understand and...
2
by: UNIXNewBie | last post by:
Please excuse the basic nature of these questions - I'm just starting off. This example is taken from Oracle PL/SQL 101 - Osborne/McGraw-Hill - ISBN 0-07-212606-X - page 314 Numbers to the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.