Перевести маленький кусок кода с VB на C#
Формулировка задачи:
Public Class Job
Public arrivalT As Integer
Public burstT As Integer
Public waitingT As Integer
Public turnaroundT As Integer
Public name As String
Public Shared cnt As Integer = 0
Public progress As ProgressBar
Public lblburst As Label
Public lblwait As Label
Public finishT As Integer = 0
Public Sub New()
Dim ctr As Integer
Dim temp As Integer
Dim flag As Boolean = False
Randomize()
''''this do..while loop is used to assign unique arrival time
Do
temp = randm()
flag = False
For ctr = 0 To 10
If temp = form1.unique(ctr) Then
flag = True
End If
Next
If flag = False Then
form1.unique(cnt) = temp
cnt += 1
End If
Loop While flag = True
arrivalT = temp
burstT = CInt(Int((12 * Rnd()) + 1))
waitingT = 0
turnaroundT = 0
End Sub
Private Function randm() As Integer
Return CInt(Int((10 * Rnd()) + 0))
End Function
End Classusing System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace VBtoCSharp
{
public class Job
{
public int arrivalT;
public int burstT;
public int waitingT;
public int turnaroundT;
public string name;
public static int cnt = 0;
public ProgressBar progress;
public Label lblburst;
public Label lblwait;
public int finishT = 0;
public Job()
{
int ctr;
int temp;
Boolean flag = false; }Решение задачи: «Перевести маленький кусок кода с VB на C#»
textual
Листинг программы
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
public class Job
{
public int arrivalT;
public int burstT;
public int waitingT;
public int turnaroundT;
public string name;
public static int cnt = 0;
public ProgressBar progress;
public Label lblburst;
public Label lblwait;
public int finishT = 0;
public Job()
{
int ctr = 0;
int temp = 0;
bool flag = false;
VBMath.Randomize();
///'this do..while loop is used to assign unique arrival time
do {
temp = randm();
flag = false;
for (ctr = 0; ctr <= 10; ctr++) {
if (temp == form1.unique(ctr)) {
flag = true;
}
}
if (flag == false) {
form1.unique(cnt) = temp;
cnt += 1;
}
} while (flag == true);
arrivalT = temp;
burstT = Convert.ToInt32(Conversion.Int((12 * VBMath.Rnd()) + 1));
waitingT = 0;
turnaroundT = 0;
}
private int randm()
{
return Convert.ToInt32(Conversion.Int((10 * VBMath.Rnd()) + 0));
}
}