using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        delegate double func(double x);
        delegate void Multi_Cast(ref int x);
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //func f = new func(Math.Sin);
            //func f = Math.Sin;                
            //MessageBox.Show(f(30*Math.PI/180).ToString());

            //f = CosD;
            //MessageBox.Show(f(60).ToString());

            //func[] f = new func[4];
            //f[0] = Math.Sin;
            //f[1] = Math.Cos;
            //f[2] = Math.Tan;
            //f[3] = CoTan;
            //for(int i=0;i<4;i++)    
            //    MessageBox.Show(f[i](30*Math.PI/180).ToString());

            //int a = 5;
            //Multi_Cast f = test1;
            //f += test2;
            ////f -= test1;
            //f(ref a);

            //func f = delegate(double x)  //Function Without Name
            //{
            //    double r = x * Math.PI / 180;
            //    return (Math.Cos(r));
            //};

            //func f = (double x) =>  //Lambda Operator
            //{
            //    double r = x * Math.PI / 180;
            //    return (Math.Cos(r));
            //};
            
            //func f=(double x) =>Math.Cos( x * Math.PI / 180);

           //func f = x => Math.Cos(x * Math.PI / 180);

            func f = x => x * x;
            MessageBox.Show(f(60).ToString());


        }

        static double CoTan(double r)
        {
            return (1 / Math.Tan(r));
        }

        static double CosD(double d)
        {
            double r = d * Math.PI / 180;
            return (Math.Cos(r));
        }

        static void test1(ref int x)
        {
            x++;
        }
        static void test2(ref int x)
        {
            MessageBox.Show(x.ToString());
        }

    }
}
