C# Functions Part 1


C# Functions: Function Multiply() and MultiplyIt()

class Program  // Functions Part 1
{
    static void WriteStuff() {
        WriteLine("from WriteStuff()");
    }
    static void Main(string[] args) {
        WriteStuff();  // call the function
        WriteLine (Multiply(3.4, 98.1));
        WriteLine(MultiplyIt(2.1, 3.5));
        ReadKey();
    }
    static double Multiply(double myVal1, double myVal2)
    {
        WriteLine("from Multiply()");
        return myVal1 * myVal2;
    }
    static double MultiplyIt(double myV1, double myV2) => myV1 * myV2;  
	// => Lamda is new in C# 6
}

Leave a comment

Your email address will not be published. Required fields are marked *