-
小心VB.NET中的除运算符"/"和"\"
Sub Main()
Console.WriteLine("请输入一个整数:")
F1(Console.ReadLine())
Console.ReadLine()
End Sub
Public Sub F1(ByVal times As Integer)
Dim list As ArrayList = New ArrayList()
'填充数据
For i As Integer = 0 To 29
list.Add(i)
Next
'把集合list中元素分成times份进行处理
Dim oneTimeNum As Integer = list.Count / times
For i As Integer = 0 To times - 1
Dim length As Integer = oneTimeNum
If i = times - 1 Then
'最后一次循环取集合中所有剩余数据
length = list.Count - oneTimeNum * i
End If
'实际中这里是启动线程处理,这里简化只是来说明问题
F2(list.GetRange(oneTimeNum * i, length))
Next
End Sub
Private Sub F2(ByVal al As ArrayList)
'对ArrayList集合al进行处理
End Sub
.method public static void F1(int32 times) cil managed
{
// 代码大小 123 (0x7b)
.maxstack 3
.locals init ([0] class [mscorlib]System.Collections.ArrayList list,
[1] int32 oneTimeNum,
[2] int32 i,
[3] int32 V_3,
[4] int32 length,
[5] int32 VB$t_i4$L0,
[6] int32 VB$CG$t_i4$S0,
[7] bool VB$CG$t_bool$S0)
IL_0000: nop
IL_0001: newobj instance void [mscorlib]System.Collections.ArrayList::.ctor()
IL_0006: stloc.0
IL_0007: ldc.i4.0
IL_0008: stloc.2
IL_0009: ldloc.0
IL_000a: ldloc.2
IL_000b: box [mscorlib]System.Int32
IL_0010: callvirt instance int32 [mscorlib]System.Collections.ArrayList::Add(object)
IL_0015: pop
IL_0016: nop
IL_0017: ldloc.2
IL_0018: ldc.i4.1
IL_0019: add.ovf
IL_001a: stloc.2
IL_001b: ldloc.2
IL_001c: ldc.i4.s 29
IL_001e: stloc.s VB$CG$t_i4$S0
IL_0020: ldloc.s VB$CG$t_i4$S0
IL_0022: ble.s IL_0009
IL_0024: ldloc.0
IL_0025: callvirt instance int32 [mscorlib]System.Collections.ArrayList::get_Count()
IL_002a: conv.r8
IL_002b: ldarg.0
IL_002c: conv.r8
IL_002d: div
IL_002e: call float64 [mscorlib]System.Math::Round(float64) //重点看这句
IL_0033: conv.ovf.i4
IL_0034: stloc.1
IL_0035: ldc.i4.0
IL_0036: ldarg.0
IL_0037: ldc.i4.1
IL_0038: sub.ovf
IL_0039: stloc.s VB$t_i4$L0
IL_003b: stloc.3
IL_003c: br.s IL_0070
IL_003e: ldloc.1
IL_003f: stloc.s length
IL_0041: ldloc.3
IL_0042: ldarg.0
IL_0043: ldc.i4.1
IL_0044: sub.ovf
IL_0045: ceq
IL_0047: stloc.s VB$CG$t_bool$S0
IL_0049: ldloc.s VB$CG$t_bool$S0
IL_004b: brfalse.s IL_0059
IL_004d: ldloc.0
IL_004e: callvirt instance int32 [mscorlib]System.Collections.ArrayList::get_Count()
IL_0053: ldloc.1
IL_0054: ldloc.3
IL_0055: mul.ovf
IL_0056: sub.ovf
IL_0057: stloc.s length
IL_0059: nop
IL_005a: ldloc.0
IL_005b: ldloc.1
IL_005c: ldloc.3
IL_005d: mul.ovf
IL_005e: ldloc.s length
IL_0060: callvirt instance class [mscorlib]System.Collections.ArrayList [mscorlib]System.Collections.ArrayList::GetRange(int32,
int32)
IL_0065: call void VBTest.Module1::F2(class [mscorlib]System.Collections.ArrayList)
IL_006a: nop
IL_006b: nop
IL_006c: ldloc.3
IL_006d: ldc.i4.1
IL_006e: add.ovf
IL_006f: stloc.3
IL_0070: ldloc.3
IL_0071: ldloc.s VB$t_i4$L0
IL_0073: stloc.s VB$CG$t_i4$S0
IL_0075: ldloc.s VB$CG$t_i4$S0
IL_0077: ble.s IL_003e
IL_0079: nop
IL_007a: ret
} // end of method Module1::F1
栏目列表
最新更新
python爬虫及其可视化
使用python爬取豆瓣电影短评评论内容
nodejs爬虫
Python正则表达式完全指南
爬取豆瓣Top250图书数据
shp 地图文件批量添加字段
爬虫小试牛刀(爬取学校通知公告)
【python基础】函数-初识函数
【python基础】函数-返回值
HTTP请求:requests模块基础使用必知必会
SQL SERVER中递归
2个场景实例讲解GaussDB(DWS)基表统计信息估
常用的 SQL Server 关键字及其含义
动手分析SQL Server中的事务中使用的锁
openGauss内核分析:SQL by pass & 经典执行
一招教你如何高效批量导入与更新数据
天天写SQL,这些神奇的特性你知道吗?
openGauss内核分析:执行计划生成
[IM002]Navicat ODBC驱动器管理器 未发现数据
初入Sql Server 之 存储过程的简单使用
uniapp/H5 获取手机桌面壁纸 (静态壁纸)
[前端] DNS解析与优化
为什么在js中需要添加addEventListener()?
JS模块化系统
js通过Object.defineProperty() 定义和控制对象
这是目前我见过最好的跨域解决方案!
减少回流与重绘
减少回流与重绘
如何使用KrpanoToolJS在浏览器切图
performance.now() 与 Date.now() 对比