-
小心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
栏目列表
最新更新
求1000阶乘的结果末尾有多少个0
详解MyBatis延迟加载是如何实现的
IDEA 控制台中文乱码4种解决方案
SpringBoot中版本兼容性处理的实现示例
Spring的IOC解决程序耦合的实现
详解Spring多数据源如何切换
Java报错:UnsupportedOperationException in Col
使用Spring Batch实现批处理任务的详细教程
java中怎么将多个音频文件拼接合成一个
SpringBoot整合ES多个精确值查询 terms功能实
数据库审计与智能监控:从日志分析到异
SQL Server 中的数据类型隐式转换问题
SQL Server中T-SQL 数据类型转换详解
sqlserver 数据类型转换小实验
SQL Server数据类型转换方法
SQL Server 2017无法连接到服务器的问题解决
SQLServer地址搜索性能优化
Sql Server查询性能优化之不可小觑的书签查
SQL Server数据库的高性能优化经验总结
SQL SERVER性能优化综述(很好的总结,不要错
uniapp/H5 获取手机桌面壁纸 (静态壁纸)
[前端] DNS解析与优化
为什么在js中需要添加addEventListener()?
JS模块化系统
js通过Object.defineProperty() 定义和控制对象
这是目前我见过最好的跨域解决方案!
减少回流与重绘
减少回流与重绘
如何使用KrpanoToolJS在浏览器切图
performance.now() 与 Date.now() 对比