Step: 1 Create New website (http://manas6/aspnet.35/mm.DelegateImplicit1/Default.aspx)

Step: 2 Edit Codes

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>mm.DelegateImplicit: LamdaExpression</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="L1" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
 

Default.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public delegate int del(int i);
public delegate void FunctionPointer(string str);
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// var q1 = from
FunctionPointer fp = delegate(string s) { L1.Text += (s); };
fp("Hello World! Explicit Way");
// implicit
del myDelegate = x => x * x;
int j = myDelegate(5);
L1.Text += "<br/> implicit del myDelegate = x => x * x; &nbsp = " + j;
// explicit
int y = 25;
del myDelegate2 = (int x) => x + y;
int j2 = myDelegate2(5);
L1.Text += "<br/>explicit del myDelegate2 = (int x) => x + y; &nbsp = " + j2;
}
}

}
 

Step: 3 Runtime analysis