委托问题:S [英] Delegate problems :S

查看:82
本文介绍了委托问题:S的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

原始代码

public void HashTorrent(TorrentManager manager)
       {
           // Note: The manager must be in the ''Stopped'' state in order to perform
           // a hash check. Also, to make the sample easier the event handler
            // is not unregistered. In your application be careful you don''t
          // accidentally attach a new event handler every time the torrent is hashed
          manager.PieceHashed += delegate (object o, PieceHashedEventArgs e);
               int pieceIndex = e.PieceIndex;
               int totalPieces = e.TorrentManager.Torrent.Pieces.Count;
              double progress = (double) pieceIndex / totalPieces * 100.0;
             if (e.HashPassed)
                  Console.WriteLine("Piece {0} of {1} is complete", pieceIndex, totalPieces);
               else
                   Console.WriteLine("Piece {0} of {1} is corrupt or incomplete ", pieceIndex, totalPieces);

               // This shows how complete the hashing is.
               Console.WriteLine("Total progress is: {0}%", progress);

              // This shows the percentage completion of the download. This value
              // is updated as the torrent is hashed or new pieces are downloaded
               Console.WriteLine("{0}% of the torrent is complete");
          };

           // If ''true'' is passed, the torrent will automatically go to the ''Downloading'' or ''Seeding''
           // state once the hash check is finished. Otherwise it will return to the ''Stopped'' state.
            manager.HashCheck(false);
    }



我的问题是我无法将此行转换为vb.net



my problem is i cant convert this line to vb.net

manager.PieceHashed += delegate (object o, PieceHashedEventArgs e);

推荐答案

此处:
manager.PieceHashed += Sub(o As Object, e As PieceHashedEventArgs)
    ' ...
End Sub


您每次需要翻译某些内容时都无法提出这样的问题.这是您可以使用的Web工具:
http://www.developerfusion.com/tools/convert/csharp-to-vb/ [ ^ ].

此外-请参阅我对这个问题的评论-我不确定此类翻译在所有情况下是否有意义.也许您只是应该了解,您可以在任何.NET解决方案中自由地混合使用不同.NET语言编写的项目.您可以使用不同的语言开发单独的程序集,特别是如果您想使用一些可用的代码,然后可以引用其他程序集中的某些程序集.这是将引用的程序集用作库的方法.

-SA


You cannot ask such questions every time you need to translate something. Here is the Web tool you can use:
http://www.developerfusion.com/tools/convert/csharp-to-vb/[^].

Besides — please see my comment to the question — I''m not sure such translation makes sense in all cases. Perhaps you simply should understand that you can freely mix up project written in different .NET languages in any .NET solution. You can just develop separate assemblies in different languages, especially if you want to use some available code, and then you can reference some assembly in some other assembly; this is the way to use a referenced assembly as a library.

—SA


从C#转换为VB.Net [ ^ ]


这篇关于委托问题:S的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆