Saturday, April 26, 2025

C# - Method Parameters and Default Params

using System;

namespace LearnCS
{
    class Program
    {

        static void Calc(double x, double y) {
            Console.WriteLine("Add: " + (x + y));
            Console.WriteLine("Sub: " + (x - y));
            Console.WriteLine("Mul: " + (x * y));
            Console.WriteLine("Div: " + (x / y));
        }

        static void Person(string x, string y) {
            string result = x + " " + y;
            Console.WriteLine(result);

        }

        static void DefDef(int x = 10) {
            Console.WriteLine(x * 2);
        }

        static void Main(string[] args)
        {

            //Calc(10.50, 5.25);
            //Calc(10, 5);

            //Person("John", "Snow");

            DefDef(50);
            DefDef();
            DefDef(100);

        }        
    }
}

 

No comments:

Post a Comment

Tkinter Introduction - Top Widget, Method, Button

First, let's make shure that our tkinter module is working ok with simple  for loop that will spawn 5 instances of blank Tk window .  ...