A Function or a method in any programming language is something that will do some kind of operations by taking in some values and process those values and return the result when it is called.
It has different syntax for creating and calling in different programming languages for example in c# it is like:
Example:
Creating a function:
public int Add(int firstnumber, int lastnumber)
{
return firstnumber+lastnumber;
}
So here:
Public: This is the access specifier
int: Is the return type
int firstnumber, int lastnumber: Are the two input parameters of int data type
firstnumber+lastnumber : This is the operation done for the input values
return : This is the keyword for returning the result which must be the same type as of the function return type.
Calling a function:
int resultA = Add(1,2);
This will call the function Add by passing 1 and 2 as input parameters and the returned result will be stored in the variable resultA.
Popular Posts
-
Here is the code: // => Brute Force Solution: O(m* n) static long arrayManipulation(int n, int[][] queries) { ...
-
Whatever it is one fine day everyone on this planet who are born have to die for sure. When you are close ones are with you, you wont know ...
-
HTML: <div class="outer-container"> <div class="inner-container"> <div class="t...
No comments:
Post a Comment