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.9k
Extension Method modified
Dec 18 2014 8:29 AM
http://www.dotnetperls.com/extension
Program in the above website is modified to work with the Reference Parameter. What changes have to be made to get the
Dot net perls
output in the Main() method. Problem is highlighted.
using System;
//class ExtensionMethods
//{
// public static string UppercaseFirstLetter(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";
UppercaseFirstLetter(
ref
value); // Called like an instance method.
Console.WriteLine(value);//Dot net perls
Console.ReadKey();
}
public static void UppercaseFirstLetter(
ref
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]);
string s = new string(array);
Console.WriteLine(s);
//return new string(array);
}
//return value;
}
}
Reply
Answers (
2
)
.net
Regex and split