class method in c# code example
Example 1: C# Class Members
class MyClass
{
string color = "red";
int maxSpeed = 200;
public void fullThrottle()
{
Console.WriteLine("The car is going as fast as it can!");
}
}
Example 2: how to call a method from a class C#
classname.methodname();
Example 3: how to call a method from a class in c#
using System;
namespace CalculatorApplication {
class NumberManipulator {
public int FindMax(int num1, int num2) {
int result;
if (num1 > num2)
result = num1;
else
result = num2;
return result;
}
static void Main(string[] args) {
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();
}
}
}