简体   繁体   English

使用对象将vb.net转换为c#

[英]Converting vb.net to c# with Object

I have the following vb.net line: 我有以下vb.net行:

Dim applesAs Object() = New Object([end] - startIndex - 1) {}

and Developer Fusion's Converter converts it to this c# line: 然后Developer Fusion的Converter将其转换为以下c#行:

object[] apples= new object[end - startIndex - 1];

The c# code seems to create an array of objects called apples, however I cannot find what the constructor for Object in vb is doing. C#代码似乎创建了一个称为apples的对象数组,但是我找不到vb中Object的构造函数正在做什么。 Is it also creating an array? 它也在创建数组吗? Am I wrong about what the c# line seems to be doing? 我对C#行似乎在做什么感到不对吗?

however I cannot find what the constructor for Object in vb is doing. 但是我找不到vb中Object的构造函数正在做什么。

Its not a constructor call, () are used in VB.Net for array indexing. 它不是构造函数调用, ()在VB.Net中用于数组索引。

Also there is no constructor accepting a parameter with Object 也没有构造函数接受Object的参数

Both the vb.net and c# code are creating an object array called apples. vb.net和c#代码都在创建一个名为apples的对象数组。

  • c# uses [] to indicate an array c#使用[]表示数组
  • vb.net uses () to indicate an array vb.net使用()表示一个数组

The parameters set the size of the array 参数设置数组的大小

new Object(5) 'vb.net
new object[6] //c#

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM