c# Use a lambda expression to define an event handler

来源:互联网 发布:华润置地 知乎 面试 编辑:程序博客网 时间:2024/05/19 04:28

Use a lambda expression to define an event handler


using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;namespace WindowsFormsApplication1{    public partial class Form1 : Form    {        public Form1()        {            InitializeComponent();            // Use a lambda expression to define an event handler.            this.Click += (s, e) =>            {                MessageBox.Show(                    ((MouseEventArgs)e).Location.ToString());            };        }    }}


0 0
原创粉丝点击