Re: Delphi type events in C#
- From: Kerem Gümrükcü <kareem114@xxxxxxxxxxx>
- Date: Mon, 9 Mar 2009 04:11:03 +0100
Hi John,
have a look at these examples, they are pretty good
to understand:
http://msdn.microsoft.com/en-us/library/aa645739(VS.71).aspx
Thats a good one (just flying over it, looks good):
http://www.akadia.com/services/dotnet_delegates_and_events.html
regards
Kerem
--
--
----------------------- Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project: http://www.pro-it-education.de/software/deviceremover
Latest Open-Source Projects: http://entwicklung.junetz.de
----------------------- "This reply is provided as is, without warranty express or implied."
"JM" <me@xxxxxxxx> schrieb im Newsbeitrag news:eUkLIHGoJHA.2272@xxxxxxxxxxxxxxxxxxxxxxx
Hi,.
Being a Delphi programmer from way back (14 years) and new to C#, I was wondering if someone would be kind enough to explain how to create events in C# for non-visual controls/classes.
In Delphi, it's similar to..
procedure TMyNewEvent (Sender: TObject; MyStream: TStream; var MyFlag: boolean) Of Object;
In the containing class, it looks sort of like..
MyClass = class(TObject); // TPersistent or any TObject based class..
private
FOnMyEvent: TMyNewEvent;
protected
procedure DoMyEvent(Sender: TObject; AStream: TStream; var AFlag: boolean);
property OnMyNewEvent: TOnMyEvent Read FOnMyEvent Write DoMyEvent;
published
..
end;
And is then written as..
procedure MyClass.DoMyEvent(Sender: TObject; AStream: TStream; var AFlag: boolean);
begin
// do something here..
If Assigned(FOnMyEvent) Then
FOnMyEvent(Self, AStream, AFlag);
end;
In C#'lish, what would it look like?
I'm guessing callbacks/delegates or something similarly foreign to me.
I've only been looking at C# a few weeks and its similarities to Delphi are really quite remarkable in some areas..but, not this one.
Thanks in advance.
John McTaggart
- References:
- Delphi type events in C#
- From: JM
- Delphi type events in C#
- Prev by Date: Delphi type events in C#
- Next by Date: Re: Delphi type events in C#
- Previous by thread: Delphi type events in C#
- Next by thread: Re: Delphi type events in C#
- Index(es):
Relevant Pages
|