官术网_书友最值得收藏!

Reference returns

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; 
} 
主站蜘蛛池模板: 图们市| 鄱阳县| 临汾市| 定西市| 寿光市| 阿克苏市| 九寨沟县| 中阳县| 陆河县| 洮南市| 乐业县| 荥经县| 临沧市| 喀喇| 宁安市| 高台县| 筠连县| 蕉岭县| 怀安县| 海淀区| 达孜县| 深圳市| 雅江县| 河池市| 方山县| 内黄县| 同德县| 新干县| 夏河县| 桑植县| 呈贡县| 石景山区| 万宁市| 通州区| 潞城市| 都江堰市| 湖北省| 余干县| 凤城市| 彭州市| 大洼县|