Seshadri M

Seshadri M

  • NA
  • 69
  • 17.7k

Extension methods implemented for odd or even number

Oct 9 2017 9:49 PM
//I have try this code but i am not getting relevant output
 //if enter even number i am gettting output as odd number
static class numbers {
public static string iseven(this int i)
{
if (i / 2 == 0)
{
return "Even number";
}
return "odd number";
}
}
class Program
{
static void Main(string[] args)
{
int r = Convert.ToInt32(Console.ReadLine());
string s = r.iseven();
Console.WriteLine(s);
Console.ReadLine();
}
}
}

Answers (2)