Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > Can I extend methods of Double Class ?
 

Can I extend methods of Double Class ?

Can I Extend method of Double Class?

eg:

Double value;

then I can use

value.Foobar(); just like value.ToString(); where Foobar is my own extended function of Double Class.

laue  Thursday, March 27, 2008 2:39 AM
sure here is an example.


Code Snippet

static string FooBar(this double value)
{
return "FooBar" + value.ToString();
}


AbdElRaheim  Thursday, March 27, 2008 3:13 AM
Note you need to be using VS 2008 to be able to use extension methods

http://msdn2.microsoft.com/en-us/library/bb383977.aspx
Ken Tucker  Thursday, March 27, 2008 3:41 AM
sure here is an example.


Code Snippet

static string FooBar(this double value)
{
return "FooBar" + value.ToString();
}


AbdElRaheim  Thursday, March 27, 2008 3:13 AM
Note you need to be using VS 2008 to be able to use extension methods

http://msdn2.microsoft.com/en-us/library/bb383977.aspx
Ken Tucker  Thursday, March 27, 2008 3:41 AM

Where should I put this code?
laue  Thursday, March 27, 2008 5:12 AM

If I work with .net 2.0

How Can I finished the same work?

laue  Thursday, March 27, 2008 5:26 AM

Sorry you need to be using .net Framework 3.5 to be able to use extension methods

Ken Tucker  Thursday, March 27, 2008 10:21 AM

You can use google to search for other answers

Custom Search

More Threads

• BindingSource IsDirty Property
• Clear a DataGrid
• ComboBox data binding problem
• Filtering a dataset and adding a new item
• Almost there: populating datagrid (not using dataset)
• SetDataBinding syntax help.
• Add item to databound listbox
• C# DataGridView AllowUserToOrderColumns
• .NET IDE Corrupts DataSet Designer file ?
• Strange EvaluateException