Good afternoon. I rewrote the library from C # to a more convenient for myself VB.NET and could not figure out how to write two pieces of code.

Code 1.

throw new RucaptchaErrorException((RucaptchaError)Enum.Parse(typeof(RucaptchaError), str.Substring(6))); 

Attempting to get at least some code through a decompiler looks like this:

 Throw New RucaptchaErrorException(DirectCast(Enum.Parse(GetType(RucaptchaError), Str.Substring(6)), RucaptchaError)) 

Code 2

 public object Clone() { var paramsContainer = new ParamsContainer(); foreach (var obj in from object index in Params.Keys select (Param) Params[index]) paramsContainer.Params.Add(obj.Key, obj); return paramsContainer; } 

When you try to convert this method, the decompiler has completely demolished the roof and the resulting piece is not even worth bringing.

Please help.

  • And what decompiler do you use? My ILSpy did quite well, sort of (but that was a long time ago). - VladD

1 answer 1

Code 1:

 Throw New RucaptchaErrorException(DirectCast(System.Enum.Parse(GetType(RucaptchaError), str.Substring(6)), RucaptchaError)) 

Code 2:

 Option Infer On Public Function Clone() As Object Dim paramsContainer = New ParamsContainer() For Each obj In From index As Object In Params.Keys Select CType(Params(index), Param) paramsContainer.Params.Add(obj.Key, obj) Next obj Return paramsContainer End Function 

ps may be errors, used the converter: http://www.tangiblesoftwaresolutions.com/Free_Edition_Downloads/Instant%20VB%20(Free%20Edition)%20Setup.exe

  • one
    Thank you so much!!! - Dmitriy Gvozd