如何做到这一点vb 2010

时间:2010-12-09 22:24:23

标签: c# vb.net

Int32 number = new Random().Next();
Console.WriteLine(number);

Func<Int32> GenerateRandom = delegate() { return new Random().Next(); };

Console.WriteLine("Begin Call");
GenerateRandom.DoAsync(number => Console.WriteLine(number));
Console.WriteLine("End Call"); 

5 个答案:

答案 0 :(得分:2)

Dim number As Int32 = New Random().[Next]()
Console.WriteLine(number)

Dim GenerateRandom As Func(Of Int32) = Function() New Random().[Next]()

Console.WriteLine("Begin Call")
GenerateRandom.DoAsync(Function(number) Console.WriteLine(number))
Console.WriteLine("End Call")

答案 1 :(得分:2)

Dim number As Int32 = New Random().[Next]()
Console.WriteLine(number)

Dim GenerateRandom As Func(Of Int32) = Function() New Random().[Next]()

Console.WriteLine("Begin Call")
GenerateRandom.DoAsync(Function(number) Console.WriteLine(number))
Console.WriteLine("End Call")

答案 2 :(得分:2)

Heres'是一个翻译。

Dim random = New Random()
Dim number = random.Next()
Console.WriteLine(number)

Dim GenerateRandom = Function ()
    Dim random = New Random()
    Dim number = random.Next()
  End Function

Console.WriteLine("Begin Call")
GenerateRandom.DoAsync(Sub (number) Console.WriteLine(number))
Console.WriteLine("End Call")

答案 3 :(得分:2)

以下是http://converter.telerik.com/的快速代码转换。我测试了它似乎工作。

Dim number As Int32 = New Random().[Next]()
Console.WriteLine(number)

Dim GenerateRandom As Func(Of Int32) = Function() New Random().[Next]()

Console.WriteLine("Begin Call")
GenerateRandom.DoAsync(Function(number) Console.WriteLine(number))
Console.WriteLine("End Call")

答案 4 :(得分:1)

Reflector是一种在.NET语言之间进行转换的简单而自由的方式。