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
>
[email protected]
>