0

im converting string to code for runtime compile using code dom, so i really need to know if its possible to call static method with 'this double', before i manage to write more complex code to produce correct string

i have method

public static double Test(this double x)
{
   //some code here...
}

and i want to call it like

double d = 5.Test();//Compiler Error: Cannot resolve symbol Test

i know this is possible for strings but i cant do the same thing for double. how can i do this also if its not possible why its possible for string? thanks for help.

M.kazem Akhgary
  • 18,645
  • 8
  • 57
  • 118

1 Answers1

10

declare your 5 as a double, right now it's an integer.

double d = 5D.Test();

Here's the list of numeric suffixes C# uses.

Community
  • 1
  • 1
Jonesopolis
  • 25,034
  • 12
  • 68
  • 112