0

I am a beginner in c# programming. I was trying to make a scientific calculator to start with the basics. I have made a full functioning calculator using JavaScript ( as a static web page). I want to use some of the functions written in JavaScript in my windows form application. I don't want to write the same logic code again in c#. There must be some technology to support cross platform programming. Somebody please guide me. Thanks.

  • Either use the web browser control and open the page you already have, or do the smart thing and convert them to C#. – ProgrammingLlama Nov 23 '20 at 13:29
  • "There must be some technology to support cross platform programming." - nope – Dai Nov 23 '20 at 13:29
  • 1
    If your JavaScript will run in an ECMAScript 3 (circa 1999) environment, then you could invoke and run it via `wscript`/`cscript`. You'll need to use some tricks to pass values into functions declared in that script though. – Dai Nov 23 '20 at 13:30
  • You can look at using https://www.nuget.org/packages/Microsoft.AspNetCore.SpaServices.Extensions, but that's really not meant for your use case. You're better off rewriting your JavaScript code as C#. – Heretic Monkey Nov 23 '20 at 13:49

1 Answers1

1

You can open a webview and load your html content into it (https://learn.microsoft.com/en-us/microsoft-edge/webview2/gettingstarted/winforms). For furher integration of JS into C# refer to parse and execute JS by C#, but I'd suggest that it is easier to rewrite the JS code into C#...

Klemikaze
  • 369
  • 6
  • 15