Arrays in Visual Basic

后端 未结 5 1990
长发绾君心
长发绾君心 2020-12-12 04:34

In declaring an array in VB, would you ever leave the zero element empty and adjust the code to make it more user friendly?

This is for Visual Basic 2008

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-12 05:20

    • Most of my VB.Net arrays are 0-based and every element is used. That's usual in VB.Net and code mustn't surprise the reader. Readability is vital.
    • Any exceptions? Maybe if I had a program ported from VB6, so it used 0-based arrays with unused initial elements, and it needed a small change, I might match the pattern of the existing code. Least surprise again.
    • 99 times out of 100 the question shouldn't arise because you should be using List(Of T) rather than an array!

提交回复
热议问题