|
-
Aug 14th, 2006, 09:27 AM
#1
Thread Starter
Addicted Member
*** RESOLVED *** Implementing a method
I am new to C# and am having trouble translating the following line from VB.net to C#:
VB Code:
Public Sub BeforeNavigate2(ByVal pDisp As Object, ByRef URL As String, ByRef flags As Object, ByRef targetFrameName As String, ByRef postData As Object, ByRef headers As String, ByRef cancel As Boolean) Implements DWebBrowserEvents2.BeforeNavigate2
' Do stuff...
End Sub
What I have so far is:
VB Code:
public void BeforeNavigate2(Object pDisp, String URL, Object flags, String targetFrameName, Object postData, String headers) { // Do stuff... }
But when compiling, I get the following error:
Error 1 'ModifiableWebBrowser.WebBrowserExtendedEvents' does not implement interface member 'ModifiableWebBrowser.DWebBrowserEvents2.BeforeNavigate2(object, string, object, string, object, string)'. 'ModifiableWebBrowser.WebBrowserExtendedEvents.BeforeNavigate2(object, string, object, string, object, string)' is either static, not public, or has the wrong return type. C:\Documents and Settings\jmcdonald\My Documents\Visual Studio 2005\Projects\WindowsApplication3\WindowsApplication3\ModifiableWebBrowser.cs 81 18 WindowsApplication3
I know that I need to tell the app that this method is implementing the DWebBrowserEvents2.BeforeNavigate2 method, but can not figure out the syntax. I have searched for the syntax for this but must be searching by the wrong criteria as I have not found anything yet. Help?
Last edited by finn0013; Aug 14th, 2006 at 09:52 AM.
-
Aug 14th, 2006, 09:52 AM
#2
Thread Starter
Addicted Member
Re: Implementing a method
Nevermind... I was trying to return void when it really returned Boolean...
-
Aug 14th, 2006, 06:33 PM
#3
Re: *** RESOLVED *** Implementing a method
You've also got to include the 'ref' keyword before the arguments that are ByRef in the VB code. Note that you also need to add the 'ref' keyword befroe the parameter when you call the method.
-
Aug 14th, 2006, 07:17 PM
#4
Thread Starter
Addicted Member
Re: *** RESOLVED *** Implementing a method
Thanks, I didn't know that. I assumed that every object was passed by reference unless you specifically specified to pass by value - java habits.
-
Aug 14th, 2006, 07:20 PM
#5
Re: *** RESOLVED *** Implementing a method
Passing by value (in only) is the default and you explicitly specify 'ref' (in/out) or 'out' (out only).
-
Aug 15th, 2006, 05:59 PM
#6
Fanatic Member
Re: *** RESOLVED *** Implementing a method
It's really the reference to the object that's passed by reference. If you pass an object by value you can still change it's data in the method and have those changes visible in the caller. It's a lot different than in the days of C++. Passing by reference simply allows you to assign a new object to that variable and have that assignment reflected in the calling method too.
The human brain cannot hold all of the knowledge that exists in this world, but it can hold pointers to that knowledge.
-
Aug 16th, 2006, 07:26 AM
#7
Thread Starter
Addicted Member
Re: *** RESOLVED *** Implementing a method
That makes more sense to me. Thanks for the clarification.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|