当前位置: 首页 > news >正文

电影网站建设之苹果cms/北京百度推广优化

电影网站建设之苹果cms,北京百度推广优化,手提包 东莞网站建设,大城县有做网站的吗与所有的 out 参数一样,在使用数组类型的 out 参数前必须先为其赋值,即必须由接受方为其赋值。例如:public static void MyMethod(out int[] arr) {arr new int[10]; // definite assignment of arr } 与所有的 ref 参数一样,…

 

与所有的 out 参数一样,在使用数组类型的 out 参数前必须先为其赋值,即必须由接受方为其赋值。例如:

public static void MyMethod(out int[] arr) 
{arr = new int[10];   // definite assignment of arr
}

与所有的 ref 参数一样,数组类型的 ref 参数必须由调用方明确赋值。因此不需要由接受方明确赋值。可以将数组类型的 ref 参数更改为调用的结果。例如,可以为数组赋以 null 值,或将其初始化为另一个数组。例如:

public static void MyMethod(ref int[] arr) 
{arr = new int[10];   // arr initialized to a different array
}

下面的两个示例说明 outref 在将数组传递给方法上的用法差异。

示例 1

在此例中,在调用方(Main 方法)中声明数组 myArray,并在 FillArray 方法中初始化此数组。然后将数组元素返回调用方并显示。

None.gif// cs_array_ref_and_out.cs
None.gif
using System; 
None.gif
class TestOut 
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif   
static public void FillArray(out int[] myArray) 
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif      
// Initialize the array:
ExpandedSubBlockStart.gifContractedSubBlock.gif
      myArray = new int[5dot.gif{12345};
ExpandedSubBlockEnd.gif   }

InBlock.gif
InBlock.gif   
static public void Main() 
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif      
int[] myArray; // Initialization is not required
InBlock.gif
InBlock.gif      
// Pass the array to the callee using out:
InBlock.gif
      FillArray(out myArray);
InBlock.gif
InBlock.gif      
// Display the array elements:
InBlock.gif
      Console.WriteLine("Array elements are:");
InBlock.gif      
for (int i=0; i < myArray.Length; i++)
InBlock.gif         Console.WriteLine(myArray[i]);
ExpandedSubBlockEnd.gif   }

ExpandedBlockEnd.gif}

None.gif

输出
Array elements are:
1
2
3
4
5

示例 2

在此例中,在调用方(Main 方法)中初始化数组 myArray,并通过使用 ref 参数将其传递给 FillArray 方法。在 FillArray 方法中更新某些数组元素。然后将数组元素返回调用方并显示。

None.gif// cs_array_ref_and_out2.cs
None.gif
using System; 
None.gif
class TestRef 
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif   
public static void FillArray(ref int[] arr) 
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif      
// Create the array on demand:
InBlock.gif
      if (arr == null)
InBlock.gif         arr 
= new int[10];
InBlock.gif      
// Otherwise fill the array:
InBlock.gif
      arr[0= 123;
InBlock.gif      arr[
4= 1024;
ExpandedSubBlockEnd.gif   }

InBlock.gif
InBlock.gif   
static public void Main () 
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif      
// Initialize the array:
ExpandedSubBlockStart.gifContractedSubBlock.gif
      int[] myArray = dot.gif{1,2,3,4,5};  
InBlock.gif
InBlock.gif      
// Pass the array using ref:
InBlock.gif
      FillArray(ref myArray);
InBlock.gif
InBlock.gif      
// Display the updated array:
InBlock.gif
      Console.WriteLine("Array elements are:");
InBlock.gif      
for (int i = 0; i < myArray.Length; i++
InBlock.gif         Console.WriteLine(myArray[i]);
ExpandedSubBlockEnd.gif   }

ExpandedBlockEnd.gif}

None.gif
输出
Array elements are:
123
2
3
4
1024

转载于:https://www.cnblogs.com/syveen/articles/190786.html

http://www.jmfq.cn/news/4848013.html

相关文章:

  • 新疆建设云资质查询网站/百度地图下载2022新版安装
  • 网站建设 常用字体/爱站权重查询
  • 做不锈钢百度网站哪个比较好/最新新闻事件
  • 物联网的网络架构/德兴网站seo
  • 安徽省建设部干部网站/域名归属查询
  • 中山百度网站排名/长尾词挖掘免费工具
  • 一起做玩具网站/企业网站排名优化
  • 阳泉建设局网站/seo运营专员
  • 怎么用html做移动网站/百度权重提升
  • 汉鼎中国 网站建设/西安疫情最新数据消息5分钟前
  • 国家建设网站/营销网络推广方式有哪些
  • 怎样推广广告/山东seo多少钱
  • 保定比较好的网站建设公司/平台软件定制开发
  • 国内很多网站不是响应式/市场调查报告
  • 网站开发建设及推广合同/推广策略有哪些方法
  • 直播app定制开发/成都关键词优化平台
  • 武汉集团网站建设/北京网站推广排名外包
  • wordpress修改固定链接打不开/天津seo培训机构
  • 烟台网络公司员工人数/搜索引擎优化简称
  • 网站案例分析/中山排名推广
  • 网站托管主要干点什么/网络营销是什么工作主要干啥
  • 眉山政府网站建设/北京百度总部电话
  • 购物网站免费模板/拼多多关键词排名查询软件
  • 甘肃省人民政府官网首页/百度seo竞价推广是什么
  • 泸州网站公司/做一个官网要多少钱
  • wordpress 知名站点/网络营销专业学什么课程
  • 中企动力科技股份有限公司干嘛的/宁波seo教学
  • 学习网站建设总结/厦门谷歌seo
  • 顺企网上海网站建设/深圳网络推广服务是什么
  • 小程序开发平台需要网站吗/营销培训总结