C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Iterator,Delegate,Predicates,Anonymous method and Generics C#2.0


Posted Date: 07 May 2007    Resource Type: Code Snippets    Category: Collections

Posted By: santosh narayan poojari       Member Level: Silver
Rating:     Points: 10



A perfect blend of Iterator,Delegate,Predicates,Anonymous method and Generics C#2.0. One can make use of these in real world scenario to save memory and increase performance of an application.

Delegates defines signature of any method that takes one input parameter and returns a single object of another type.

public delegate Tout Action(Tin element);
protected void Page_Load(object sender, EventArgs e)
{
foreach (string str in GetFormatedCustomerName())
Response.Write(str);
}
public IEnumerable GetFormatedCustomerName()
{
List customerList=new List();
customerList.Add(new Customer("001", "Santosh",3552));
customerList.Add(new Customer("002", "Poojari", 42424));
customerList.Add(new Customer("005", "Arjun", 42424));

return BuildFormattedName(customerList,
delegate(Customer objCustomer)
{
return string.Format("{0} - {1}
", objCustomer.CustomerId, objCustomer.CustomerName);
});
}
public IEnumerable BuildFormattedName(IEnumerable list, Action handler)
{
foreach (Tin entry in list)
yield return handler(entry);
}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Copy bytes from one array to another using Buffer Class
Previous Resource: Anonymous Methods in C#
Return to Discussion Resource Index
Post New Resource
Category: Collections


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

teleconferencing service

Contact Us    Privacy Policy    Terms Of Use