Click here to Skip to main content
13,139,834 members (79,702 online)
Click here to Skip to main content
Articles » Languages » C# » General » Downloads

Tagged as

Stats

71.9K views
149 bookmarked
Posted 12 Oct 2011

How does it work in C#? - Part 2

, 4 Feb 2013
How does throw, rethrow and where, select clause of Enumerable class work in C# programming language.
Demo
TestHarnessPart2.exe
HowDoesItWork
HowDoesItWork.sln.vsdoc
HowDoesItWork.suo
TestHarness
bin
Debug
TestHarness.exe
TestHarness.pdb
TestHarness.vshost.exe
TestHarness.vshost.exe.manifest
obj
x86
Debug
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
TestHarness.exe
TestHarness.pdb
Properties
TestHarness.vsdoc
TestHarnessPart2
bin
Debug
TestHarnessPart2.exe
TestHarnessPart2.pdb
TestHarnessPart2.vshost.exe
Release
obj
x86
Debug
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
TestHarnessPart2.exe
TestHarnessPart2.pdb
Properties
TestHarnessPart2.vsdoc
´╗┐namespace TestHarness
{
    using System;
    using System.Collections.Generic;
    using System.Linq;

    public class AddRemoveHandlerOfEvent
    {

        public LogIt InitialiseLogIt()
        {
            LogIt logItObject = new LogIt();
            logItObject.Log += new LogIt.LogHandler(Logger1);
            logItObject.Log += new LogIt.LogHandler(Logger1);
            logItObject.Log += new LogIt.LogHandler(Logger3);
            return logItObject;
        }

        public IEnumerable<string> GetInitialMethodPointer()
        {
            return GetType().GetMethods().Select(methodInfo => string.Format("{0,40}-->{1,20}", methodInfo.Name, methodInfo.MethodHandle.Value.ToString()));
        }

        public IEnumerable<string> GetInvocationListFrom(LogIt logItObject)
        {
            return logItObject.GetList().Select(delegateObject => string.Format("{0,40}-->{1,20}", delegateObject.Method.Name, delegateObject.Method.MethodHandle.Value.ToString()));
        }

        public void Logger1(string s)
        {
            Console.WriteLine(s);
        }
        public void Logger2(string s)
        {
            Console.WriteLine(s);
        }
        public void Logger3(string s)
        {
            Console.WriteLine(s);
        }

    }

    public class LogIt
    {
        public delegate void LogHandler(string message);
        public event LogHandler Log;
        public Delegate[] GetList()
        {
            return Log.GetInvocationList();
        }
    }
}



By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author


You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170915.1 | Last Updated 4 Feb 2013
Article Copyright 2011 by Mohammad A Rahman
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid