TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Maha
NA
600
70.8k
Extension Method and Directive
Dec 17 2014 6:32 AM
http://www.dotnetperls.com/extension
This program is given in the above website.
In this program directive
using
Extensions
; is not used. Please tell what is the reason for that?
In my view return type and variable in question are same type that is why directive is not used. I wish to know whether my understanding is correct. Problem is highlighted.
using System;
public
static
class ExtensionMethods
{
public static string UppercaseFirstLetter(this string value)
{
//
// Uppercase the first letter in the string this extension is called on.
//
if (value.Length > 0)
{
char[] array = value.ToCharArray();
array[0] = char.ToUpper(array[0]);
return new string(array);
}
return value;
}
}
class Program
{
static void Main()
{
//
// Use the string extension method on this value.
//
string
value = "dot net perls";
value = value.UppercaseFirstLetter(); // Called like an instance method.
Console.WriteLine(value);//Dot net perls
Console.ReadKey();
}
}
Reply
Answers (
6
)
How to Insert Data.when textboxes are generated dynamically
how to selected row in GridView on LinkButton Click event?