Converting C# to VB.Net - Need some help
(Source/Credits: https://dev.to/bugmagnet/converting-c-to-vb-net-need-some-help-11k5)
using System; using System.Collections.Generic; namespace PreHOPL { static class Program {...
```csharp using System; using System.Collections.Generic;
namespace PreHOPL
{
static class Program
{
private static readonly Dictionary
private static void Main(string[] args)
{
dict["SAYLIT"].Item2.DynamicInvoke("Hello World!");
}
}
} ``` I've just tried 4 diferent online tools (Telerik, ICSharpCode, Carlosag and DeveloperFusion) to convert this to VB.Net for a colleague. Three have spat a long error message and the fourth is spinning its wheels going nowhere. Ideas?
Comments section
bugmagnet Author
•May 1, 2024
Building on @raphaelgodart 's approach and utilising
ValueTuple
:``` Module Module1 Private Const sSayLit As String = "SAYLIT" Private ReadOnly dict As Dictionary( Of String, (Arity As Integer, Proc As [Delegate]) ) = New Dictionary( Of String, (Arity As Integer, Proc As [Delegate]) ) From { {sSayLit, (1, CType(AddressOf Console.WriteLine, Action(Of String)))} }
End Module
```
raphaelgodart
•May 1, 2024
First of all, I'm afraid this code is as human readable as it is machine readable. I suggest some refactoring. After 30 minutes, I was able to come up with this translation to VB.Net:
``` Imports System Imports System.Collections.Generic
Namespace PreHOPL Module Program Private ReadOnly dict As Dictionary(Of String, Tuple(Of Integer, Action(Of String))) = New Dictionary(Of String, Tuple(Of Integer, Action(Of String))) From {{"SAYLIT", New Tuple(Of Integer, Action(Of String))(1, CType(AddressOf System.Console.WriteLine, Action(Of String)))}}
End Namespace
```
bugmagnet Author
•May 1, 2024
Thank you for spending so much time on it. I wonder if
ValueTuple
would simplifying it at all.