Exercise 1 : A singer is "observed" by fans 1, 2 and 3, and then fan 3 "unsubscribes" :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EventsAndDelegatesExercise
{
    class Program
    {
        static void Main(string[] args)
        {
            // new singer
            Singer singer = new Singer("some singer");

            Fan fan1 = new Fan("fan1");
            Fan fan2 = new Fan("fan2");
            Fan fan3 = new Fan("fan3");

            // fans "observing" the singer created above
            fan1.subscribe(singer);
            fan2.subscribe(singer);
            fan3.subscribe(singer);

            singer.Compose("Song 1"); // fans should be notified of the new song

            fan3.unsubscribe(singer);

            singer.Compose("Song 2");
        }
    }
}

=============================================

using System;

namespace EventsAndDelegatesExercise
{

    // signature definition / interface of the delegate
    public delegate void SongIsOut(Object sender, Song songEventArgs);

    
    class Singer
    {
        // actual instantiation of our delegate :
        public event SongIsOut NewSongIsOut;
        public string SingerName { get; set; }

        public Singer(string p)
        {
            // TODO: Complete member initialization
            this.SingerName = p;
        }
        // could be also : 
        // public event EventHandler SongReady;

        public void Compose(string SongName) {
            if (NewSongIsOut != null)
                NewSongIsOut(this, new Song(SongName));
        }
    }

    public class Song
    {
        public string songName { get; set; }
        public Song(String songName)
        {
            this.songName = songName;
        }
    }

}

=============================================

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EventsAndDelegatesExercise
{
    class Fan
    {
        public string FanName { get; private set; }

        public Fan(string FanName)
        {
            this.FanName = FanName;
         }



 
        private void ProducerSongReady(object sender, Song song)
        {
            Console.WriteLine("{0}: {1}", FanName, song.songName);
        }

        internal void unsubscribe(Singer singer)
        {
            singer.NewSongIsOut -= ProducerSongReady;
            Console.WriteLine("Fan " + FanName + " has unsubscribed from singer " + singer.SingerName);
        }

        internal void subscribe(Singer singer)
        {
            singer.NewSongIsOut += ProducerSongReady;
            Console.WriteLine("Fan "+FanName+" has subscribed to singer "+singer.SingerName);
        }
    }
}
Exercise 2 : --annotions-- Attributes and reflection. Write a program that scans a class whose methods are annotated with a reviewer name (or not) and prints out smthg like : method abc reviewed by Mr A method def not reviewed ... Main class :
using System;
using System.Text;
using System.Reflection;

namespace AttributeTest
{
    class Program {

        static void Main(string[] args)
        {
            MyTestClass myTestClass = new MyTestClass();

            foreach (MethodInfo methodInfo in myTestClass.GetType().GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static))
            {
                bool reviewed = false;
                foreach (ReviewerAttribute attribute in methodInfo.GetCustomAttributes(typeof(ReviewerAttribute), true))
	            {
                    Console.WriteLine("Method " + methodInfo.Name + " reviewed by "+attribute.reviewer);
                    reviewed = true;
	            }

                if (!reviewed) {
                    Console.WriteLine("Method "+methodInfo.Name+" should be reviewed");
                }

            }

        }
    }

    class MyTestClass
    {

        [Reviewer("Nicolas")]
        public void DoIt()
        {
        }

        [Reviewer("Nicolas")]
        public void DoIt1()
        {
        }

        public void DoIt2()
        {
        }
    }
}
============================================= --Annotation-- Attribute class :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AttributeTest
{
    [AttributeUsage(AttributeTargets.All)]
    class ReviewerAttribute : System.Attribute
    {

        public ReviewerAttribute(string reviewer)
        {
            this.reviewer = reviewer;
        }

        public string reviewer { get; set; }
    }
}