Jon Skeet said:
At doing what? Unless you've got unsafe code involved, I can't think of
many things off-hand that you can't do exactly the same way in VB.NET,
resulting in virtual identical IL.
Try following code and Compare the results. Remember compare "remarked"
code also.
I would said C# is not a "superior" but "faster" language.
Sorry for ugly C# code, I'm not skillful in C#. (^^
<VB>
Public Class Form1
Dim watch As New System.Diagnostics.Stopwatch
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim val(7) As Long, t As Long
watch.Start()
For i As Long = 1 To 10000
For j As Long = 0 To 255
val(0) = (j And 1) + 48
val(1) = (j And 2) / 2 + 48
val(2) = (j And 4) / 4 + 48
val(3) = (j And 8) / 8 + 48
val(4) = (j And 16) / 16 + 48
val(5) = (j And 32) / 32 + 48
val(6) = (j And 64) / 64 + 48
val(7) = (j And 128) / 128 + 48
'val(0) = (j And 1) + 48
'val(1) = ((j And 2) >> 1) + 48
'val(2) = ((j And 4) >> 2) + 48
'val(3) = ((j And 8) >> 3) + 48
'val(4) = ((j And 16) >> 4) + 48
'val(5) = ((j And 32) >> 5) + 48
'val(6) = ((j And 64) >> 6) + 48
'val(7) = ((j And 128) >> 7) + 48
Next
Next
watch.Stop()
t = watch.ElapsedMilliseconds
Text1.Text = t
watch.Reset()
End Sub
End Class
<C#>
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
namespace crt
{
public partial class Form1 : Form
{
private Stopwatch Watch;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
long t;
long[] bit = new long[8];
Watch = new Stopwatch();
Watch.Start();
for (long i = 1; i <= 10000; i++)
{
for (long j = 0; j <= 255; j++)
{
bit[0]= (j & 1) + 48;
bit[1] = (j & 2) / 2 + 48;
bit[2] = (j & 4) / 4 + 48;
bit[3] = (j & 8) / 8 + 48;
bit[4] = (j & 16) / 16 + 48;
bit[5] = (j & 32) / 32 + 48;
bit[6] = (j & 64) / 64 + 48;
bit[7] = (j & 128) / 128 + 48;
/*bit[0]= (j & 1) + 48;
bit[1] = ((j & 2) >>1) + 48;
bit[2] = ((j & 4) >>2) + 48;
bit[3] = ((j & 8) >>3) + 48;
bit[4] = ((j & 16) >>4) + 48;
bit[5] = ((j & 32) >>5) + 48;
bit[6] = ((j & 64) >>6) + 48;
bit[7] = ((j & 128) >> 7) + 48;*/
}
}
Watch.Stop();
t = Watch.ElapsedMilliseconds;
text1.Text = t.ToString();
Watch.Reset();
}
}
}