对象的矢量即时VBNet

Vector of an object instant VB Net

本文关键字:VBNet 对象      更新时间:2023-10-16

我在VBNET中遇到向量问题。

我用C++写了一段代码

typedef struct
{
    int process;
    int burstTime;
    int ArrivalTime;
    int remaining;
    int timeAddedToQ;
    bool flag;
} process;
vector<process> proc;

如何在VBNET代码中表示这个C++代码?

我试着在谷歌上搜索,但没有任何帮助。如果有人能帮助,我会非常感激

感谢

您通常会为Process信息创建一个类,然后使用List(Of Process)来替换vector<process>

Public Class Process
    Property Process As Integer
    Property BurstTime As Integer
    Property ArrivalTime As Integer
    Property Remaining As Integer
    Property Flag as Boolean
End Class
' Use in code as:
Dim proc as New List(Of Process)
VB中的结构声明如下:
Public Structure process
    Public process As Integer 
    Public burstTime As Integer
    Public ArrivalTime As Integer
    Public remaining As Integer
    Public timeAddedToQ As Integer
    Public flag As Boolean
End Structure

但是,您应该确定您想要的是一个结构,而不是一个类。vector没有到VB的直接翻译,但List<T>可能是最接近的:

Dim proc As New List(Of process)