FindMax number method
using System;
namespace CalculatorApplication
{
class NumberManipulator
{
public int FindMax(int num1,int num2)
{
//local variable declaration
int result;
if (num1 > num2)
{
return num1;
}
else
return num2;
return result;
}
static void Main(string[] args)
{
//local variable declaration
int a = 100;
int b = 200;
int ret;
NumberManipulator n = new NumberManipulator();
ret = n.FindMax(a,b);
Console.WriteLine("Max value is : {0}",ret);
Console.ReadLine();
}
}
}
output:
Max value is : 200
Recursive Method Call
using System;
namespace CalculatorApplication
{
class NumberManipulator
{
public int factorial(int num)
{
//local variable declaration
int result;
if (num==1)
{
return 1;
}
else
result= factorial(num-1)*num;
return result;
}
static void Main(string[] args)
{
NumberManipulator n = new NumberManipulator();
Console.WriteLine("Factorial of 6 is : {0}", n.factorial(6));
Console.ReadLine();
}
}
}
Factorial of 6 is :720
using System;
namespace CalculatorApplication
{
class NullablesAtShow
{
static void Main(string[] args)
{
int? num1 = null;
double? num2 = 24;
double? num3 = new double();
double? num4 = 3.1415;
bool? boolval = new bool?();
// display the values
Console.WriteLine("Nullables at Show: {0}, {1}, {2}, {3}", num1, num2, num3, num4);
Console.WriteLine("A Nullable boolean value: {0}", boolval);
Console.ReadLine();
}
}
}