Click here to Skip to main content
15,901,666 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
How can we convert JS code into C#

What I have tried:

Tried online tools didnt help as such
Posted
Updated 26-Jul-23 20:14pm

Basically, don't. It really won't work well.
Javascript ruins on the client in a browser sandbox, and the range of things it can do is pretty much limited to user interaction.
C# runs on the client and does not interact with the user directly (unless you create a Windows app or similar).

Even if you do try to convert it, the tools and frameworks are totally different, and what works well in one language does not work well in a different one using a totally different framework. Imagine trying to get a Truck engine to work in a Mini car and you'll see the problem: you could do it, with some cutting, welding, and a lot of swearing, but what you end up with isn't a usable vehicle.

Use the JS code as a specification for a new C# app instead. It'll be quicker in the long run, and will produce better code in the end.
 
Share this answer
 
Comments
Andre Oosthuizen 14-Jul-20 7:09am    
Agree 100%, 5 kudo's, Mini will be nice enough project though if you have nothing to do. :)
function hex_reachable(start, movement):
    var visited = set() # set of hexes
    add start to visited
    var fringes = [] # array of arrays of hexes
    fringes.append([start])

    for each 1 < k ≤ movement:
        fringes.append([])
        for each hex in fringes[k-1]:
            for each 0 ≤ dir < 6:
                var neighbor = hex_neighbor(hex, dir)
                if neighbor not in visited and not blocked:
                    add neighbor to visited
                    fringes[k].append(neighbor)

    return visited
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900