Program :

Sample Output :
CSharp-Add-Two-Nums-using-Function

Explanation :

In the above program the method static public int Add(int a,int b) , we are declaring method Sum method as Static because Main method is static and we are calling Sum method in Main method without creating object.

C# is a Object Oriented Programming Language. And in OOP language, a method can be called using object of a class. And if we want to call method without creating object, we have to declare it as static to Call it with its class name.

original post link

Leave a Reply

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