April 2018
Intermediate to advanced
300 pages
7h 41m
English
Reference returns allows a method to return an object as a reference instead of its value. We can define the reference return value by adding a ref keyword before the type in the method signature and when returning the object from the method itself.
Here is the signature of the method that allows reference returns:
public ref Person GetPersonInformation(int ID);
Following is the implementation of the GetPersonInformation method that uses the ref keyword while returning the person's object.
Person _person;
public ref Person GetPersonInformation(int ID)
{
_person = CallPersonHttpService();
return ref _person;
}
Read now
Unlock full access