Click here to Skip to main content
15,896,063 members
Home / Discussions / C#
   

C#

 
GeneralRe: Problem with socket.recieve() , when the clent disconnect Pin
Ennis Ray Lynch, Jr.2-Feb-11 9:32
Ennis Ray Lynch, Jr.2-Feb-11 9:32 
GeneralRe: Problem with socket.recieve() , when the clent disconnect Pin
jschell3-Feb-11 9:28
jschell3-Feb-11 9:28 
AnswerRe: Problem with socket.recieve() , when the clent disconnect Pin
jschell1-Feb-11 14:13
jschell1-Feb-11 14:13 
Questionoverloading Console.write() [modified] Pin
KARFER1-Feb-11 5:03
KARFER1-Feb-11 5:03 
AnswerRe: overloading Console.write() Pin
Pete O'Hanlon1-Feb-11 5:06
mvePete O'Hanlon1-Feb-11 5:06 
GeneralRe: overloading Console.write() Pin
KARFER1-Feb-11 5:11
KARFER1-Feb-11 5:11 
GeneralRe: overloading Console.write() Pin
Pete O'Hanlon1-Feb-11 5:12
mvePete O'Hanlon1-Feb-11 5:12 
AnswerRe: overloading Console.write() Pin
Not Active1-Feb-11 5:48
mentorNot Active1-Feb-11 5:48 
QuestionRe: overloading Console.write() Pin
TheGreatAndPowerfulOz1-Feb-11 7:13
TheGreatAndPowerfulOz1-Feb-11 7:13 
AnswerRe: overloading Console.write() Pin
Eddy Vluggen1-Feb-11 7:34
professionalEddy Vluggen1-Feb-11 7:34 
JokeRe: overloading Console.write() Pin
fjdiewornncalwe1-Feb-11 8:20
professionalfjdiewornncalwe1-Feb-11 8:20 
GeneralRe: overloading Console.write() Pin
Eddy Vluggen1-Feb-11 8:37
professionalEddy Vluggen1-Feb-11 8:37 
AnswerRe: overloading Console.write() Pin
Luc Pattyn1-Feb-11 8:44
sitebuilderLuc Pattyn1-Feb-11 8:44 
GeneralRe: overloading Console.write() Pin
Henry Minute1-Feb-11 11:16
Henry Minute1-Feb-11 11:16 
GeneralRe: overloading Console.write() Pin
Eddy Vluggen1-Feb-11 20:28
professionalEddy Vluggen1-Feb-11 20:28 
QuestionUsing virtual mode list view to monitor events queue? Pin
Chesnokov Yuriy1-Feb-11 3:47
professionalChesnokov Yuriy1-Feb-11 3:47 
QuestionHow to add both x86 and x64 class library to the references in the project Pin
Chesnokov Yuriy1-Feb-11 3:06
professionalChesnokov Yuriy1-Feb-11 3:06 
AnswerRe: How to add both x86 and x64 class library to the references in the project Pin
Pete O'Hanlon1-Feb-11 3:57
mvePete O'Hanlon1-Feb-11 3:57 
GeneralRe: How to add both x86 and x64 class library to the references in the project Pin
RobCroll1-Feb-11 12:34
RobCroll1-Feb-11 12:34 
GeneralRe: How to add both x86 and x64 class library to the references in the project Pin
Chesnokov Yuriy1-Feb-11 18:53
professionalChesnokov Yuriy1-Feb-11 18:53 
AnswerRe: How to add both x86 and x64 class library to the references in the project Pin
jschell1-Feb-11 10:40
jschell1-Feb-11 10:40 
QuestionAbstract classes and delgates Pin
igalep1321-Feb-11 2:22
igalep1321-Feb-11 2:22 
AnswerRe: Abstract classes and delgates PinPopular
DaveyM691-Feb-11 4:00
professionalDaveyM691-Feb-11 4:00 
GeneralRe: Abstract classes and delgates Pin
igalep1325-Feb-11 9:03
igalep1325-Feb-11 9:03 
GeneralRe: Abstract classes and delgates Pin
DaveyM695-Feb-11 10:57
professionalDaveyM695-Feb-11 10:57 
Ah, I see your problem.

The delegate itself can't be abstract but an instance of it (including an event) can. See the sample and test code below.
C#
using System;

class Program
{
    static void Main(string[] args)
    {
        new Test().Run();
        Console.ReadKey();
    }
}

class Test
{
    public void Run()
    {
        B b = new B();
        b.Xxx += new DelegateXxx(b_Xxx);
        C c = new C();
        c.Xxx += new DelegateXxx(c_Xxx);
        A ab = b as A;
        ab.Xxx += new DelegateXxx(ab_Xxx);
        A ac = c as A;
        ac.Xxx += new DelegateXxx(ac_Xxx);

        b.DoXxx();
        Console.WriteLine();
        ab.DoXxx();
        Console.WriteLine();
        c.DoXxx();
        Console.WriteLine();
        ac.DoXxx();
        Console.WriteLine();
    }
    private void b_Xxx(object sender, EventArgs e)
    {
        Console.WriteLine("b_Xxx Raised");
    }
    private void c_Xxx(object sender, EventArgs e)
    {
        Console.WriteLine("c_Xxx Raised");
    }
    private void ab_Xxx(object sender, EventArgs e)
    {
        Console.WriteLine("ab_Xxx Raised");
    }
    private void ac_Xxx(object sender, EventArgs e)
    {
        Console.WriteLine("ac_Xxx Raised");
    }
}

public delegate void DelegateXxx(object sender, EventArgs e);

public abstract class A
{
    public abstract event DelegateXxx Xxx;

    public abstract void DoXxx();
    protected abstract void OnXxx(EventArgs e);
}

public class B : A
{
    public override event DelegateXxx Xxx;

    public override void DoXxx()
    {
        OnXxx(EventArgs.Empty);
    }
    protected override void OnXxx(EventArgs e)
    {
        Console.WriteLine("Raising from B");
        DelegateXxx delegateXxx = Xxx;
        if (delegateXxx != null)
            delegateXxx(this, e);
    }
}

public class C : A
{
    public override event DelegateXxx Xxx;

    public override void DoXxx()
    {
        OnXxx(EventArgs.Empty);
    }
    protected override void OnXxx(EventArgs e)
    {
        Console.WriteLine("Raising from C");
        DelegateXxx delegateXxx = Xxx;
        if (delegateXxx != null)
            delegateXxx(this, e);
    }
}

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)



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.