C#和VB.Net中数组的起始索引 [英] Starting Index of Arrays in C# and VB.Net
本文介绍了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屋!
查看全文