I'm using WebClient
in a .NET 4.7.2 WinForms application. I calling the UploadProgressChanged
event, which receives an UploadProgressChangedEventArgs
object. I'd like to add a extra property to the event args, so I'm trying to extend UploadProgressChangedEventArgs
as UploadProgressChangedExtEventArgs
.
public class UploadProgressChangedExtEventArgs : UploadProgressChangedEventArgs {
public UploadProgressChangedExtEventArgs() { }
public string Message { get; set; }
}
However, I get the error "CS1729: 'UploadProgressChangedEventArgs' does not contain a constructor that takes 0 arguments."
According to the documentation (and Object Browser seems to support this) UploadProgressChangedEventArgs
doesn't have a constructor -- like, at all -- though it's base object ProgressChangedEventArgs
does. I've tried using base()
to supply the arguments to the ProgressChangedEventArgs
constructor, but then I get "does not contain a constructor that takes 2 arguments" error.
Am I just not able to inherit from UploadProgressChangedEventArgs
object? Is this a bug in .NET? Am I missing something obvious?
question from:
https://stackoverflow.com/questions/66048209/cannot-inherit-from-event-args-class-no-contructor 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…