Implementing an Interface (C# to VB syntax confusion)

bri189a

Well-known member
Joined
Sep 11, 2003
Messages
1,004
Location
VA
Okay, more stuff... in c# when I type:

Public WebForm1 : System.Web.UI.Page, ITest

Intellisense tells me to press tab to put the interface stubs in... Im not getting that in my VB (2002) IDE ... thats a great feature... all I get in VB is the blue squiggles saying I have to use such an inteface...

Also....

Public ReadOnly Property TestProperty() As Object Implements ITest.TestProperty

This is how VB implements an interface???!!!! What a pain... especially if I cant have the stubs automatically put in....and how come I can change the name and it still implements correctly and compiles as in:

Public ReadOnly Property Blah() As Object Implements ITest.TestProperty
 
The required subs and functions are automatically put in by Intellisense

Public Class Irrational Intellisense automatically places End Class if you press Enter.
Implements IFormattable Intellisense automatically places the ToString function if you press Enter.

and how come I can change the name and it still implements correctly and compiles as in:
Both are implementing the same member of the ITest interface and you have supplied the correct parameter signature (namely, no parameters).

Its similar to the Handles keyword for handling events. You can name the event procedure anything you want, as long as it is handling the right event and has the appropriate parameter signature (the same one that the delegate has).
 
Not working!

Gotcha.... thanks... I really prefer C#, do you know how many lines Ive been ending with a semi-colon? :P

...I tried just hitting return afterwards and Intellisense didnt add a thing (other than the squiggly that said I need to implement the members)... is this because its 2002 instead of 2003?
 
Well I found that by going to the events drop down and selecting an event that hasnt been implemented yet it does the same thing (puts the function and signature in for me)... there has to be better a way though.
 
Gotcha.... thanks... I really prefer C#, do you know how many lines Ive been ending with a semi-colon? :P
Heh heh. When I first learned C, I would conveniently forget the semi-colon on large blocks of code.
Anyway, if Intellisense doesnt add those automatically, you should be able, once again, to select the Interface that you have implemented from the upper left combobox in the code window and get the items that you have to implement.
Arent those boxes useful? ;)
 
Yeah, thats what Im doing now...so use to my C# short-cuts though :) ... when I switched from VB6 to C# it took me a while to put in the semi-colons, now if I get this job Ill have to unlearn all of that....had the interview yesterday and wasnt the best Ive ever done... totally brain-froze when asked to describe the diff. between a LEFT OUTER JOIN and a INNER JOIN.... one of those I know it...but...crap....my brain just BSODd. Its out my hands now, so well see.
 

Similar threads

G
Replies
0
Views
61
GreeeeeeeeeeeeeD
G
S
Replies
0
Views
168
SSIS_Newbie_1234
S
G
Replies
0
Views
64
Giovanni Maraschine
G
Back
Top