Reputation: 5
I decompiled a program built with .NET 1.1 and I need to rewrite in .NET 2.0 or above. I have difficulty understanding this code, and event is not my strong point. Visual Studio complains
"The event 'dataTransfering' can only appear on the hand side of += or -="
public delegate void DataTransferringDelegate(string name, long transBytes, long totalBytes);
public event DataTransferringDelegate dataTransferring
{
[MethodImpl(32)]
add
{
this.dataTransferring = (FtpIO.DataTransferringDelegate)Delegate.Combine(this.dataTransferring, value);
}
[MethodImpl(32)]
remove
{
this.dataTransferring = (FtpIO.DataTransferringDelegate)Delegate.Remove(this.dataTransferring, value);
}
}
public void upload(string fileName, bool resume)
{
long length;
long num2 = 0L;
// some code removed here
this.dataTransferring(fileName, num2, length);
}
So how to fix this code in .NET 2.0?
Upvotes: 0
Views: 64
Reputation: 1139
What you see is how compiler implements Event. You don't need those, compiler will create them automatically.
Revise your code and remove those details, like this:
public delegate void DataTransferringDelegate(string name, long transBytes, long totalBytes);
public event DataTransferringDelegate dataTransferring;
public void upload(string fileName, bool resume)
{
long length;
long num2 = 0L;
// some code removed here
dataTransferring(fileName, num2, length);
}
Upvotes: 1