Пример #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            TextBox2.Text = "Calling respective LINQ methods in the class LinqExamples..\n";

            // Using multicast Delegate in order to call all the methods
            LinqMethods linqMethods = LinqExamples.SimpleLinqQuery;

            linqMethods += LinqExamples.FilteringWithIndex;
            linqMethods += LinqExamples.SetOperations;
            // Will take up the Join() method seperately as it returns an 'object' type.

            Delegate[] delMethods = linqMethods.GetInvocationList();
            foreach (LinqMethods d in delMethods)
            {
                TextBox2.Text += "\n\nCalling method : " + d.Method.Name;
                foreach (var stu in d())
                {
                    TextBox2.Text += "\n" + stu.StuName + ", " + stu.StuClass + ", "
                                     + stu.StuTeacher + ", " + stu.TotalMarks;
                }
            }

            TextBox2.Text += "\n\nCalling method : Join\n";
            TextBox2.Text += "\n[Student]\t[Teacher]\t[Subject]\n";
            foreach (string s in LinqExamples.Join())
            {
                TextBox2.Text += s;
            }
        }