Hi Guest
MobileUser
HomePage
Jobs
WalkIn
Articles
Agile
DotNet
WebServices
Mathematics
OOPS
WEB
SharePoint
Java
DataBase
Artificial Intelligence
BigData
Android
XML
Agile
Software
SEO
Science Techonlogy
Repository Questions
PHP
Frameworks
Server
Testing
HR
Java
TPF
Tutorial
Tools
Test and Papers
Silverlight
Science Techonlogy
----- Select Country -----
----- Select Location -----
----- Select Category -----
:) Latest Topic
AJAX
VB.NET
SQL Query
UDDI
CLASS
JavaScript Questions
SharePoint Interview
SilverLight
WCF
general knowledge
ASP.NET
:) Hot Jobs
:) Latest Articles
Follow
How to use Extension Methods in C#
Question Posted on 12 Jan 2012
Home
>>
DotNet
>>
C#
>>
How to use Extension Methods in C#
Extension methods is a new feature of C# 3.0 that allows you to enhance an existing framework class by adding a new method to it without modifying the actual code of that class.Suppose you want to calculate the 4th power of an integer. For that you will have to square it two times. So instead of that you can create an Extension Method on integer
public static class ExtensionExample
{
public static int powerfour(this int myNumber)
{
return myNumber ;
}
}
Extension Methods are created in a static class and the Extension Method must be defined as static as shown above. The this keyword preceding the first parameter creates an extension method that applies to the type of that parameter. So here an Extension Method called Cube to the int type is created.
0
0
Input Your Comments Or suggestions(If Any)
Name
Email
(optional)
Comments
Other Important Questions
Simplest definition of partial classes and its rules?
Definition of Tuple class with some examples?
Define Race Condition in cSharp?
C#.Net Reserve Words
can we inherit private class level variables in c#
Top Searches:
asp net questions
vb net questions
sql query
uddl questions
class
javascript Questions
sharepoint interview questions and concept
silverlight questions and concept
wcf questions
beans
general knowledge
ajax questions
PHP
|
Biztalk
|
Testing
|
SAP
|
HR
|
Privacy policy |
Terms and Conditions
| Blog
If the copyright of any questions or content or syntax belong to you email us we will remove that(info@crackyourinterview.com or crackyourinterview2018@gmail.com)
Home
About Us
GroupChat
Sitemap
Feedback
Contact us