C# Interview Questions and Answers
<< Previous Question Next Question >>
 Question: 318 Page Views: 

How do you declare extension method for string class?



Posted By: Avi Date: 14 October 2010 12:03:31 AM
 Answer:

static class Sample { public static Function(this string s, /* other parameters */) {} }


Posted By: avibtech


Date: 14 October 2010 12:03:31 AM
Post a better Answer if you have
 
(Will show your Gravatar icon)  
  Country flag

Loading
Enter the text as shown in the image eONg5l
Related Questions
C# : How do you use nullable types?

How do you use nullable types?

int? num = null; //declaration if(num.HasValue == true) Console.Write(num.Value); else Console.Write....
Category: C# Date: 10/15/2010 3:09:46 AM
C# : How can you access system clipboard from c#?

How can you access system clipboard from c#?

By using Clipboard object. For example – SetText – sets text in clipboards, GetText – returns text f....
Category: C# Date: 10/15/2010 2:59:46 AM
C# : How do you start another process from c#?

How do you start another process from c#?

Process p = new Process(); p.StartInfo.FileName =”notepad.exe”; p.Start();
Category: C# Date: 10/15/2010 2:16:47 AM
C# : Can you declare static variable in method scope?

Can you declare static variable in method scope?

No
Category: C# Date: 10/15/2010 12:22:46 AM
C# : What will be the result of code?
int x = 3;
switch(x % 3)
{
 case 0:
 case 1:
  Console.WriteLine(x*2); break;
 default:
  Console.WriteLine(x); break;
}