Wednesday, 14 September 2016

Overloading In C#.Net

9/14/2016 - By Pranav Singh 0

Function overloading means "function with same name but different no of parameters. In this if we have same no of parameter on that case datatype must be different. In this article i have used example of c#.net.

Here i will show you an example of function overloading.

using System;

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            MethodOverloading methodoverloading = new MethodOverloading();
            Console.WriteLine(methodoverloading.DiplayData(111));
            Console.WriteLine(methodoverloading.DiplayData(1, 2));
            Console.WriteLine(methodoverloading.DiplayData(1.1f, 1.1f));
            Console.ReadLine();
        }
    }
    public class MethodOverloading
    {
        public string DiplayData(int val1)
        {
            return "Passed Value= " + val1;
        }
        public string DiplayData(int val1, int val2)
        {
            return ("Sum=" + val1 + val2);
        }
        public string DiplayData(float val1, float val2)
        {
            return ("Sum=" + (val1 + val2));
        }
    }
}


In above code you can check that in class MethodOverloading i have keep the method name same but differ with the passed parameter. Now check the output.


About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

0 comments:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Global Classified : Connectseekers.com
© 2014 aspdotnet-pools.com Designed by Bloggertheme9.
back to top