# Method

## Overloading

The return type is not part of the method signature! 主要區別在方法名稱以及參數

![](https://649662988-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAur7bcXKjIIoWcJhxZ%2F-LAurAdnh04cnJDgpxeh%2F-LAurAroqiTAQsrV5b5l%2F%E8%9E%A2%E5%B9%95%E5%BF%AB%E7%85%A7%202018-02-28%20%E4%B8%8A%E5%8D%8811.37.21.png?generation=1524627204254070\&alt=media)

## Value types v.s Reference types

![](https://649662988-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAur7bcXKjIIoWcJhxZ%2F-LAurAdnh04cnJDgpxeh%2F-LAurAsJxc2vyuMKPe9z%2F%E8%9E%A2%E5%B9%95%E5%BF%AB%E7%85%A7%202018-02-28%20%E4%B8%8A%E5%8D%8811.45.36.png?generation=1524627212638677\&alt=media)

When passing a value type to a method, a copy of that value becomes available to the method.Any change is made inside the method will not affect the short.

When passing the reference to a method, what we actually pass is a pointer to the place in memory that stores the variable.

Example : Value Types

![](https://649662988-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAur7bcXKjIIoWcJhxZ%2F-LAurAdnh04cnJDgpxeh%2F-LAurAtHrvOeOFhasDDM%2F%E8%9E%A2%E5%B9%95%E5%BF%AB%E7%85%A7%202018-02-28%20%E4%B8%8A%E5%8D%8811.49.57.png?generation=1524627203806775\&alt=media)

Example : Reference Type

![](https://649662988-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAur7bcXKjIIoWcJhxZ%2F-LAurAdnh04cnJDgpxeh%2F-LAurAtu8Syi7Cu4jlpo%2F%E8%9E%A2%E5%B9%95%E5%BF%AB%E7%85%A7%202018-02-28%20%E4%B8%8A%E5%8D%8811.58.40.png?generation=1524627205263962\&alt=media)

## Passing value types by reference (ref)

![](https://649662988-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAur7bcXKjIIoWcJhxZ%2F-LAurAdnh04cnJDgpxeh%2F-LAurAu_Ob1zx0vSPemx%2F%E8%9E%A2%E5%B9%95%E5%BF%AB%E7%85%A7%202018-02-28%20%E4%B8%8B%E5%8D%8812.03.04.png?generation=1524627204290614\&alt=media)

## Use one method return multiple value ( out keyword)

![](https://649662988-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAur7bcXKjIIoWcJhxZ%2F-LAurAdnh04cnJDgpxeh%2F-LAurAvJnaGlT9QbqdL-%2F%E8%9E%A2%E5%B9%95%E5%BF%AB%E7%85%A7%202018-02-28%20%E4%B8%8B%E5%8D%8812.11.10.png?generation=1524627194968611\&alt=media)
