Function in C#

using System;

namespace Function
{
    class Program
    {
        public void show() //no parameter
        {
            Console.WriteLine("This is a non parameterized function");

        }


        static void Main(string[] args)
        {
            Program pp=new Program();
            pp.show();

            Console.ReadLine();

        }
    }
}

 

using System;

namespace Function
{
    class Program
    {
        public void show(string message) //no parameter
        {
            Console.WriteLine("Hello "+message);

        }


        static void Main(string[] args)
        {
            Program pp=new Program();
            pp.show("zaki");

            Console.ReadLine();

        }
    }
}

using parameter and return type

using System;

namespace Function
{
    class Program
    {
        public string show(string message) //no parameter
        {
            Console.WriteLine("Inside show function");

            return message;
        }


        static void Main(string[] args)
        {
            Program pp=new Program();
           // pp.show("zaki");

            String message=pp.show("Zaki Live");
            Console.WriteLine("hello: "+message);

            Console.ReadLine();

        }
    }
}

 

It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

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