-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: Anand_2004
Message 1 in Discussion

  Hi Folks ,   In today’s session I am talking about Extension methods   
Extension method is a very interesting feature of C# 3.0.Extension method  
provides the ability to extend  the  functionality of  a existing class or  any 
existing type by writing a new  static method  and invoked through a normal 
instance method .Extension method declare through the keyword this as a 
modifier on the first parameter of the method. The below cod snippet 
demonstrates a extension method called StrLen(..) which display the string 
which is more then  4 characters long .    
using System;  
using System.Collections.Generic;  
using System.Text;  
using System.Query;  
using System.Xml.XLinq;  
using System.Data.DLinq;  
 
namespace Extension_Method  
{ 
  
public static class Extensions  
{ 
public static void StrLen(this string friendsName)  
{ 
 
if (friendsName.Length>4)  
Console.WriteLine(friendsName);  
} 
} 
  
class Program  
{ 
  
  
static void Main(string[] args)  
{ 
  
string[] friendsName = new string []{"Anand","Sasi", "Sudha" , "Arun", 
"Anjana"};  
  
foreach (string strName in friendsName)  
friendsName.StrLen(strName); 
Console.ReadLine(); 
  
} 
} 
} 
Extension method is very much useful in some certain situation  like you want 
to extent the functionality  a class or type belongs to a  3rd party library  
in your project and the library does not expose the necessary class or 
interface , through extension method you can enhance the required 
functionalities .   Please post me your queries on C# 3.0  @ [EMAIL PROTECTED]  
  Cheers Anand https://anandkumar2004.wordpress.com/

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to