We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

VB.Net to C# Conversion Help

Thread ID:

Created:

Updated:

Platform:

Replies:

14595 May 31,2004 05:33 PM Jun 2,2004 04:28 AM Windows Forms 1
loading
Tags: FAQ
Steve Graddy
Asked On May 31, 2004 05:33 PM

I am trying to convert the following VB.Net code to C# and I am getting the compiler error: VB.NET code: '' Create a delegate that will be called asynchronously Private Delegate Function GetTextData(ByVal DatabaseName As String, _ByVal ProcName As String) Dim async As New GetTextData(AddressOf TextProxy) Dim asyncResult As IAsyncResult My C# Conversion Code: // Create a delegate that will be called asynchronously private delegate void GetTextData(string DatabaseName, string ProcName); GetTextData async = new GetTextData(TextProxy); <-- Causes a compiler error IAsyncResult asyncResult; I am receiveing a compiler error of: A field initializer cannot reference the nonstatic field, method, or property ''Orgbrat.DataUtility.DBSchema.TextProxy(string, string)'' Can any of you other guys help me with this conversion. You help is much appreciated. Thanks... Steve Graddy orgbrat@orgbrat.com

Steve Graddy
Replied On June 2, 2004 04:28 AM

The answer to this was not a sysntax problem. I needed put the initializing code in the class constructor instead of putting them after the field declaration. // Create a delegate that will be called asynchronously private delegate void GetTextData(string DatabaseName, string ProcName); GetTextData async; IAsyncResult asyncResult; public MyClass { async = new GetTextData(TextProxy); } >I am trying to convert the following VB.Net code to C# and I am getting the compiler error: > > >VB.NET code: > '' Create a delegate that will be called asynchronously > Private Delegate Function GetTextData(ByVal DatabaseName As String, _ByVal ProcName As String) > > Dim async As New GetTextData(AddressOf TextProxy) > Dim asyncResult As IAsyncResult > >My C# Conversion Code: > // Create a delegate that will be called asynchronously > private delegate void GetTextData(string DatabaseName, string ProcName); > > GetTextData async = new GetTextData(TextProxy); <-- Causes a compiler error > IAsyncResult asyncResult; > >I am receiveing a compiler error of: > A field initializer cannot reference the nonstatic field, method, or property ''Orgbrat.DataUtility.DBSchema.TextProxy(string, string)'' > >Can any of you other guys help me with this conversion. You help is much appreciated. Thanks... > >Steve Graddy >orgbrat@orgbrat.com >

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;