Function Parameter in C#

function-parameter
In this chapter you will learn:

  • What is parameter?
  • How to define it in method?
  • How to pass parameter to method in C# programming?

Parameter is the essential part of function. However, it is optional but it makes C# function more dynamic than simple function. There are two type of function parameter in C#, Value type parameter and reference type parameter, that is discussed in lateral chapter in this section.

C# parameter is nothing, just a way to passing value to the function and then function calculate the value and then returns appropriate results. You can understand C# function parameter clearly in the following example.

  • Programming Example

    Output

    Power = 25
    __

    While using parameterized function, must declare valid return data type with function as follow:

    For Integer value:

    For String value:

    You can also return appropriate value with return keyword.

    Summary

    In this chapter you learned the basic of parameter in C#. You also learned a simple program of parameter. In next chapter you will learn Value type parameter in C#.


    Leave a Reply

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