I need VB.NET's "shadows" functionality inside a C# project.
I tried the "new" keyword, but it didn't seem to work, because my
particular function does in fact differ in signature to the function
that is being hidden in the base class.
In VB.NET, the shadows keyword hides all the inherited functions,
regardless of signature.
I need this functionality in C#.
I'm sure there's an easy way around this, but I am a VB.NET
programmer, and not a C# programmer.
Please C# experts, can you advise me...
TIA,
-dnw. 8 13293
Thanks for that thread url.
-dnw.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Dot net work wrote: I need VB.NET's "shadows" functionality inside a C# project.
I tried the "new" keyword, but it didn't seem to work, because my particular function does in fact differ in signature to the function that is being hidden in the base class.
In VB.NET, the shadows keyword hides all the inherited functions, regardless of signature.
I need this functionality in C#.
I'm sure there's an easy way around this, but I am a VB.NET programmer, and not a C# programmer.
Even though shadows seems to hide it, it isn't hidden. Everyone can reach
the base class methods through reflection.
FB
--
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET Blog: http://weblogs.asp.net/fbouma
Microsoft C# MVP
Hello Frans, Even though shadows seems to hide it, it isn't hidden. Everyone can reach the base class methods through reflection.
Through reflection you can also reach private members...
But you are right.
"shadows" is only a feature of Intellisence of VB.NET!!!
If you use this class in C#, you can see all members!!!
Here is a small example:
<code_vb>
Public Class Test1
Public Function F1()
End Function
Public Function F1(ByVal a As Boolean) As Long
End Function
Public Function F1(ByVal b As Int16, ByVal c As Long) As Boolean
End Function
End Class
Public Class Test2
Inherits Test1
Public Shadows Function F1(ByVal d As Double) As Double
End Function
End Class
</code_vb>
In VB.NET you will see only the Test2.F1 (via Intellisense)!
But you can also call all methods from Test1-class !!! You put the
correct parameters and it will call the method (of course, it is not
supported by intellinsense!) .
Also in C#, here you will see all 4 methods via intellisense.
--
Greetings
Jochen
Do you need a memory-leak finder ? http://www.codeproject.com/tools/leakfinder.asp
Do you need daily reports from your server? http://sourceforge.net/projects/srvreport/
Dot net work wrote: I need VB.NET's "shadows" functionality inside a C# project.
"new" is exactly the same as "shadows". But it seems to be a bug in
intellisense that it hides ALL functions with the same name.
If you use an VB.NET library in C# you will see all functions correctly.
--
Greetings
Jochen
Do you need a memory-leak finder ? http://www.codeproject.com/tools/leakfinder.asp
Do you need daily reports from your server? http://sourceforge.net/projects/srvreport/
> In VB.NET you will see only the Test2.F1 (via Intellisense)! But you can also call all methods from Test1-class !!!
Of course, you cannot call it, sorry, for the misleading sentence...
But you can call it from any other language; so it is kind of "very
special" for VB.NET...
--
Greetings
Jochen
Do you need a memory-leak finder ? http://www.codeproject.com/tools/leakfinder.asp
Do you need daily reports from your server? http://sourceforge.net/projects/srvreport/
Indeed - VB.NET seems kind of special in this case.
I like this extra functionality for the shadows keyword inside VB.NET.
("shadows" and "new" are not the same.)
I like the ability to hide base class methods, because it provides
less confusion/ambiguity for the calling code.
I tried a simple experiment in VB.NET, and the shadows keyword makes
it impossible to access base class members through simple use of
object.method calling syntax. The editor highlights the problem, and
if you go ahead and run the code anyway, it just calls the inherited
method, and not the base class method. The calling code knows nothing
about the base class method/s. (Naturally, we are talking about
methods whose names are the same, but differ in signature.)
-dnw.
Jochen Kalmbach <no************ ********@holzma .de> wrote in message news:<Xn******* *************** ************@20 7.46.248.16>... In VB.NET you will see only the Test2.F1 (via Intellisense)! But you can also call all methods from Test1-class !!!
Of course, you cannot call it, sorry, for the misleading sentence...
But you can call it from any other language; so it is kind of "very special" for VB.NET...
-- Greetings Jochen
Do you need a memory-leak finder ? http://www.codeproject.com/tools/leakfinder.asp
Do you need daily reports from your server? http://sourceforge.net/projects/srvreport/
Hello Dot net work; Indeed - VB.NET seems kind of special in this case. I like this extra functionality for the shadows keyword inside VB.NET. ("shadows" and "new" are not the same.)
Indeed, "shadows" and "new" IS tha same (at least from CLR perspective),
but VB.NET does some "special treatment" if it is a VB.NET-assembly...
I like the ability to hide base class methods, because it provides less confusion/ambiguity for the calling code.
I tried a simple experiment in VB.NET, and the shadows keyword makes it impossible to access base class members through simple use of object.method calling syntax. The editor highlights the problem, and if you go ahead and run the code anyway, it just calls the inherited method, and not the base class method. The calling code knows nothing about the base class method/s. (Naturally, we are talking about methods whose names are the same, but differ in signature.)
Yes, but this is ONLY true for VB.NET. If you use this assembly in an other
languange (like C#) you can call all methodes...
--
Greetings
Jochen
Do you need a memory-leak finder ? http://www.codeproject.com/tools/leakfinder.asp
Do you need daily reports from your server? http://sourceforge.net/projects/srvreport/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ola Johansson |
last post by:
Can anyone explain to me a meningfull use of the "new" keyword (Shadows
in VB).
I think i understand how it works fully but i cant figure out why you
would use it. Why would you want to declare a variable in a derived
class with the same name as in the base class but with a diffrent
meaning?
Anyone can think of a scenario for this?
|
by: Özden Irmak |
last post by:
Hi,
I'm trying to hide an event of my custom usercontrol derived control,
something like "Shadows" in VB.Net, but although the event is hidden from
PropertyGrid, from CodeEditor I can still see/reach it. I use this code :
|
by: Chazza |
last post by:
I would like to override a method from an inherited class, but the new
method has a different signature to the inherited class. Example:
class A {
private void Init() {
// code
}
}
class B : A {
|
by: Lino Barreca |
last post by:
Take a look at this code:
Class clsAnagrafica
Public Overridable ReadOnly Property Codice() As Integer
Get
Return 1
End Get
End Property
End Class
|
by: Larry Woods |
last post by:
I have a method in my base class that I want ALL derived classes to use.
But, I find that I can create a "Shadow" method in my derived class that
"overrides" the method in my base class. Can't figure out what attribute to
put on the base class method to prevent this.
TIA,
Larry Woods
| |
by: Dave Taylor |
last post by:
I'm trying to derive a class from a typed DataSet to add some methods to one
of the DataTables. I would like to keep the names the same in the derived
class as in the base class, so I have used "Shadows" to hide the base class
members. However, this does not seem to work. Any pointers as to what I'm
doing wrong here? (I've attached the basics of the code below). Thanks
Dave Taylor
|
by: JohnR |
last post by:
In it's simplest form, assume that I have created a usercontrol,
WSToolBarButton that contains a button. I would like to eventually create
copies of WSToolBarButton dynamically at run time based on some
initialization information obtained elsewhere. Basically, I'm going to
create my own dynamic toolbar where the toolbarbuttons can change. I'm not
using the VB toolbar because of limitations in changing things like
backcolor (I can't get...
|
by: fourfires.d |
last post by:
Dear All,
I am new to c++ and when write below code that try to call copy
constructor
in "=" operator overloading, it can not compile. Can anyone point out
for
me the reason? thanks !!
class AA
{
|
by: Nik Coughlin |
last post by:
Further to my earlier post in alt.html, I ended up preparing these pages:
http://nrkn.com/skinning/
They list different ways to "skin" an HTML element (ie add rounded corners,
drop shadows, various other graphical effects) using images while still
allowing for viewport and text re-sizing.
Anyone know of any other techniques that I've missed?
|
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...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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,...
|
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...
|
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();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |