473,809 Members | 2,708 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Differences between C# and VB "Implements "

balabaster
797 Recognized Expert Contributor
Hey, I've been trawling documentation for this, but can't figure out what it's called so I'm running short of answers:

In VB say you build some interface:
Expand|Select|Wrap|Line Numbers
  1. Interface IDemoInterface
  2.  
  3.   Sub MyFirstMethod(ByVal Param1 As String)
  4.   Sub MySecondMethod(ByVal Param1 As String)
  5.   Sub MyThirdMethod(ByVal Param1 As Integer)
  6.  
  7. End Interface
Now, you get as far as implementing that interface:
Expand|Select|Wrap|Line Numbers
  1. Public Class DemoImplementsInterface
  2.   Implements IDemoInterface
Now, as soon as you hit enter after typing the interface name that you're implementing, it automatically populates the class with the relevant methods required to implement that class:

Expand|Select|Wrap|Line Numbers
  1. Public Class DemoImplementsInterface
  2.   Implements IDemoInterface
  3.  
  4.   Public Sub MyFirstMethod(ByVal Param1 As String) Implements IDemoInterface.MyFirstMethod
  5.  
  6.   End Sub
  7.  
  8.   Public Sub MySecondMethod(ByVal Param1 As String) Implements IDemoInterface.MySecondMethod
  9.  
  10.   End Sub
  11.  
  12.   Public Sub MyThirdMethod(ByVal Param1 As Integer) Implements IDemoInterface.MyThirdMethod
  13.  
  14.   End Sub
  15.  
  16. End Class
So, I've just realised that this appears not to work in C# causing me a huge and largely unecessary amount of typing. Is there a way of forcing this to work? I thought about writing a macro to parse the interface and add the methods into my code, but it seems like a lot of work for something that at least in my mind should be automatic. Does anyone know what this process of automatically writing out the interface methods in your class is called? Maybe if I had that magic keyword, I could figure out the rest myself.
Apr 3 '08 #1
3 1615
Plater
7,872 Recognized Expert Expert
That is often an annoyance of mine too. Eclipse does it for java, why doesn't it work in C#.
Well it does, just you have to be paying really close attention.
The first letter of your interface will get a little blue line under it (like the red line when you forget to add a namespace for something) and you get two options to implement the namespace. My quick test did not show a difference in picking either option, but there must be some difference.
Apr 3 '08 #2
nateraaaa
663 Recognized Expert Contributor
Not sure if either of you use ReSharper but ReSharper will create all methods associated with the Interface that you are implementing simply by clicking on the red light bulb and selecting Implement members. If you haven't used ReSharper before I highly recommend it.

http://www.jetbrains.com/resharper/
Nathan
Apr 3 '08 #3
balabaster
797 Recognized Expert Contributor
Thanks guys - both of your posts helped. ReSharper looks like a fairly comprehensive tool - but at $349 for the license, I think I'll just pay more attention to the little marks (what are they called?) in my IDE and use the option that Plater pointed out. Maybe I'll check out ReSharper down the road when some of the other tools become of more use to me.
Apr 3 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2724
by: Stacey | last post by:
I hate to start the email with the "I'm new to this clause", but there it is. I am understanding how the xsd files work and how the castor SourceGenerator works. What I am not understanding is how the binding of a complexType to another package in java works. Basically I have in my .xsd file: <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> .. ..
11
2220
by: Antony | last post by:
I know this sounds stupid but I am going to carry on anyway. I want to create an interface that implements all methods of a form, plus another one or two. But I need to know if there is an interface that defines all a forms methods etc. In the example below "System.Windows.Forms.Form" isn't an interface, but it gets my point across. Is there an interface for a form that I can substitute here? Thank you again Tony
1
10422
by: Mitan | last post by:
Hello, I'm a beginner with what appears to be a simple question for which I haven't been able to get an answer. Can someone explain what "implementation code" is in relation to VB.NET? I want to be sure I have a good understanding of this before I continue with my studies. Thanks in advance. Semper Fi
0
1925
by: maitrepoy | last post by:
Hello I have to create a small addin which works on Powerpoint, Word, Outlook, and Excel on Office 2000, XP, and 2003. This addin consists in adding 2 new Buttons in the "File" Menu of office. This is properly done, but the events which should be triggered with the button.click method are not triggered in Word. I don't understand because it properly works in the 3 others host applications. If someone has an issue, I would be most grateful....
0
2459
by: maitrepoy | last post by:
hello I have to create a small addin which works on Powerpoint, Word, Outlook, and Excel on Office 2000, XP, and 2003. This addin consists in adding 2 new Buttons in the "File" Menu of office. This is properly done, but the events which should be triggered with the button.click method are not triggered in Word. I don't understand because it properly works in the 3 others host applications. If someone has an issue, I would be most grateful....
2
2023
by: Steve | last post by:
Kind of a strange question... I have a VB.NET 2.0 solution containing a main project (my EXE) and a number of other projects (class DLLs) that are "plug-ins" to the main app. These plugins get installed depending on each user's requirements. I'd like to implement a function in one plugin that only executes if another plugin is present. Typically, for one plugin to access a second plugin, I need to set a reference at design-time to the...
1
1854
by: Christian Welzel | last post by:
Hi there! Currently i'm thinking about how to solve this problem: if (t3lib_div::int_from_ver(phpversion())<5000000) { // php4 class tx_lib_object extends tx_lib_selfAwareness {...} // } else { // php5
11
9413
by: Wojciech Gryc | last post by:
Hi, I recently started using Python and am extremely happy with how productive it's made me, even as a new user. I'm hoping to continue using the language for my research, and have come across a bit of a stumbling block. I'm a seasoned Java programmer and quite a big fan of interfaces... i.e. The idea that if I make a number of distinct classes that implement interface X, I can pass them all as parameters to functions
4
2276
by: Tom P. | last post by:
What would the difference be between the following two: public class Foo : IList<string> { .... } public class Foo : List<string>
0
9721
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
9601
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,...
0
10637
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, 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...
1
10379
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,...
1
7660
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
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
5550
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...
0
5687
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3014
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.