码迷,mamicode.com
首页 > Windows程序 > 详细

C# 关键字out

时间:2017-08-25 13:47:42      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:unit test   pad   将不   dir   std   案例   bsp   unit   sts   

在循环中使用时需要注意

如果不赋初值创建基础数据类型被某函数调用通过out关键字标识调用时,如果处于循环之中,则该变量将不再定义时归初值。

案例:
foreach (TestUnit testUnit in ti.TestUnitList)
{
    ushort sv1, sv2, dv1, dv2;
    testUnit.AdjustSampleType =   StepAddSample.AdjustAddSampleType((StepAddSample)step  , testUnit.AdjustDilutionRatio , out sv1, out dv1, out sv2, out dv2, testUnit.IsDDLTDirectlyVolume);
}
在循环过程中ushort sv1时不再为0,因此需要重新初始化:
foreach (TestUnit testUnit in ti.TestUnitList)
{
    ushort sv1=0, sv2=0, dv1=0, dv2=0;
    testUnit.AdjustSampleType =   StepAddSample.AdjustAddSampleType((StepAddSample)step  , testUnit.AdjustDilutionRatio , out sv1, out dv1, out sv2, out dv2, testUnit.IsDDLTDirectlyVolume);
}

C# 关键字out

标签:unit test   pad   将不   dir   std   案例   bsp   unit   sts   

原文地址:http://www.cnblogs.com/sunlyk/p/7427421.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!