Step: Create site ( http://manas6/aspnet.35/mm.LINQFuncProjection1/)

Step: 2 Edit Code

FuncDelegate.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for FuncDelegate
/// </summary>
public delegate string DelegateMethod(string inString);
public class FuncDelegate
{
public Func<string, string> FuncMethod = s => s.ToUpper();

public FuncDelegate() { /* TODO: Add constructor logic here */ }

}
 

Default.aspx.

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

<!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.LINQFuncLamda1</title>
</head>
<body>
<form id="form1" runat="server" style="border: 2px solid #800000; background-color: #FFFFCC; width:500px; padding-left:10px;">
<div>
<asp:Label ID="L1" runat="server" Text=" "></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 partial class _Default : System.Web.UI.Page
{
protected string name = "this is a sentence.";
protected void Page_Load(object sender, EventArgs e)
{
// Instantiate delegate to reference UppercaseString method
FuncDelegate fd = new FuncDelegate();
L1.Text += "Direct Call fd.FuncMethod(name) writes: " + fd.FuncMethod(name);
DelegateMethod dm = new DelegateMethod(fd.FuncMethod);
L1.Text += "<br/>DelegateMethod(fd.FuncMethod) writes: " + dm(name).ToLower();
L1.Text += "<br/>DelegateMethod(fd.FuncMethod) writes: " + dm(name).ToUpper();
//
string[] words = { "january", "february", "March", "april" };
// Query the array and select strings according to the selector method.
IEnumerable<String> aWords = words.Select(fd.FuncMethod);
L1.Text+="<br/>";
// Output the results to the console.
foreach (String word in aWords)
{
L1.Text += "&nbsp" + (word);
}

}
}

 

Step: 3 Runtime analysis

Step: