473,796 Members | 2,751 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1227
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*********@gm ail.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
13470
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 left are line numbers for reference only. Hopefully I haven't made any typing mistakes. 1. DECLARE
3
1919
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 to interface with third-party libraries, get extra performance, etc. I have to use C++. Now in Python, being a dynamically typed language, everything is pushed to the run-time. Additionaly, since the language does not guarantee deterministic...
17
1158
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 something like: From a practical standpoint, objects are things that have addresses - addresses that can be computed. This doesn't necessarily mean that we can both read and write to that object -
4
6699
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 implement an Event based program and Message system. I have a very basic event engine that I'm feeling works a bit backwards. I'm looking for documents, source code, and books that may help me better understand how to implement this type of code. I am...
2
147
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 left are line numbers for reference only. Hopefully I haven't made any typing mistakes. 1. DECLARE
0
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9535
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10201
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10021
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9061
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6802
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4130
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2931
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.