Click here to Skip to main content
15,897,187 members
Home / Discussions / C#
   

C#

 
GeneralRe: abstarct class basic question Pin
PozzaVecia1-Jun-11 5:24
PozzaVecia1-Jun-11 5:24 
GeneralRe: abstarct class basic question Pin
_Erik_2-Jun-11 2:00
_Erik_2-Jun-11 2:00 
GeneralRe: abstarct class basic question Pin
PozzaVecia2-Jun-11 2:11
PozzaVecia2-Jun-11 2:11 
QuestionC# COM Interop Pin
Vijjuuu.31-May-11 19:15
Vijjuuu.31-May-11 19:15 
AnswerRe: C# COM Interop Pin
BobJanova31-May-11 23:05
BobJanova31-May-11 23:05 
AnswerRe: C# COM Interop Pin
Mirko19801-Jun-11 0:12
Mirko19801-Jun-11 0:12 
AnswerRe: C# COM Interop Pin
Eddy Vluggen1-Jun-11 0:57
professionalEddy Vluggen1-Jun-11 0:57 
AnswerRe: C# COM Interop Pin
DaveyM691-Jun-11 0:59
professionalDaveyM691-Jun-11 0:59 
I'm not sure about COM interop stuff as I've never needed it - but events are quite straight forward to add:
C#
public interface ICalculator
{
    event EventHandler CalculationPerformed;
    event EventHandler<int> CalculatedResult;

    int Add(int Number1, int Number2);
}

public class ManagedClass : ICalculator
{
    public event EventHandler CalculationPerformed;
    public event EventHandler<int> CalculatedResult;

    public int Add(int number1, int number2)
    {
        int result = number1 + number2;
        OnCalculationPerformed(EventArgs.Empty);
        OnCalculatedResult(new EventArgs<int>(result));
        return result;
    }
    protected virtual void OnCalculationPerformed(EventArgs e)
    {
        EventHandler eh = CalculationPerformed;
        if (eh != null)
            eh(this, e);
    }
    protected virtual void OnCalculatedResult(EventArgs<int> e)
    {
        EventHandler<int> eh = CalculatedResult;
        if (eh != null)
            eh(this, e);
    }
}

public delegate void EventHandler<T>(object sender, EventArgs<T> e);
public class EventArgs<T> : EventArgs
{
    private T value;

    public EventArgs(T value)
    {
        this.value = value;
    }

    public T Value
    {
        get { return value; }
    }
}

Dave

Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.
Astonish us. Be exceptional. (Pete O'Hanlon)

BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)



QuestionBitmap.SelectActiveFrame Pin
H@is@here31-May-11 12:53
H@is@here31-May-11 12:53 
QuestionLoad image that really are 2 images into imagelist Pin
manchukuo31-May-11 9:20
manchukuo31-May-11 9:20 
AnswerRe: Load image that really are 2 images into imagelist Pin
Mark Salsbery31-May-11 11:19
Mark Salsbery31-May-11 11:19 
GeneralRe: Load image that really are 2 images into imagelist Pin
manchukuo31-May-11 11:28
manchukuo31-May-11 11:28 
Questionhow to put imagens randomly? Pin
Rapsten31-May-11 5:56
Rapsten31-May-11 5:56 
AnswerRe: how to put imagens randomly? Pin
RobCroll31-May-11 13:15
RobCroll31-May-11 13:15 
QuestionRectanlgeF.Parse(string s) extension method? Pin
Chesnokov Yuriy31-May-11 1:58
professionalChesnokov Yuriy31-May-11 1:58 
AnswerRe: RectanlgeF.Parse(string s) extension method? Pin
Not Active31-May-11 2:03
mentorNot Active31-May-11 2:03 
AnswerRe: RectanlgeF.Parse(string s) extension method? Pin
Chesnokov Yuriy31-May-11 2:22
professionalChesnokov Yuriy31-May-11 2:22 
AnswerRe: RectanlgeF.Parse(string s) extension method? [modified] Pin
musefan31-May-11 2:26
musefan31-May-11 2:26 
GeneralRe: RectanlgeF.Parse(string s) extension method? Pin
Pete O'Hanlon31-May-11 2:33
mvePete O'Hanlon31-May-11 2:33 
GeneralRe: RectanlgeF.Parse(string s) extension method? Pin
musefan31-May-11 2:42
musefan31-May-11 2:42 
AnswerRe: RectanlgeF.Parse(string s) extension method? Pin
Luc Pattyn31-May-11 2:42
sitebuilderLuc Pattyn31-May-11 2:42 
AnswerRe: RectanlgeF.Parse(string s) extension method? Pin
Chesnokov Yuriy31-May-11 2:47
professionalChesnokov Yuriy31-May-11 2:47 
AnswerRe: RectanlgeF.Parse(string s) extension method? Pin
Luc Pattyn31-May-11 2:55
sitebuilderLuc Pattyn31-May-11 2:55 
GeneralRe: RectanlgeF.Parse(string s) extension method? Pin
BobJanova31-May-11 3:04
BobJanova31-May-11 3:04 
AnswerRe: RectanlgeF.Parse(string s) extension method? Pin
Luc Pattyn31-May-11 4:00
sitebuilderLuc Pattyn31-May-11 4:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.