C# 和 VB.Net 中数组的起始索引 [英] Starting Index of Arrays in C# and VB.Net

查看:46
本文介绍了C# 和 VB.Net 中数组的起始索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看看下面的代码,

C#

 string[] testString = new string[jobs.Count];

等效的 VB.Net

Dim testString() As String = New String(jobs.Count - 1) {}

为什么在创建新数组时在 vb.net 中使用 'jobs.Count - 1' 而不是 'jobs.Count'?

Why it is taking 'jobs.Count - 1' instead 'jobs.Count' in vb.net while creating new arrays?

推荐答案

在 VB.NET 中,数组声明中的数字表示最大索引",而在 C# 中则表示元素数量"

In VB.NET the number in the array declaration means "max index", but in C# it means "number of elements"

这篇关于C# 和 VB.Net 中数组的起始索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆