Click here to Skip to main content
15,606,569 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 1-Feb-23 23:54pm

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 spinWords(string){
return string.replace(/\w{5,}/g, function(w) { return w.split('').reverse().join('') })
}
 
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