不和大家卖关子,这次给大家带来的是微软粑粑前几天刚推出的新玩意:
有的小伙伴可要说了。浏览器上运行C#代码以前不即可以嘛,而后啪啪啪告诉我几个网站:C#Pad,dotnetfiddle。
重点来啦 :Tyr.Net他的功能可不只是用来在浏览器上测试代码。我这里大致的和大家讲几点功能
1.在你的网站中嵌入你的代码并进行调试
<h2>Fibonacci Generator</h2><p>Here is my example of a Fibonacci generator implemented in C#.</p><iframe src="https://try.dot.net/?fromGist=df44833326fcc575e8169fccb9d41fc7"></iframe>
function setCode() { postMessageToEditor({ type: "setWorkspace", workspace: { workspaceType: "script", buffers: [{ id: "Program.cs", content: "Console.WriteLine(\"Hello World!\");" }] }, bufferId: "Program.cs" });}function postMessageToEditor(message) { document.getElementById('example-iframe').contentWindow .postMessage(message, "https://try.dot.net");}
2.代码编辑器还支持主题的切换
比方我不喜欢黑色背景,使用下面代码就能切换成白色
function setDefaultTheme() { postMessageToEditor({ type: "configureMonacoEditor", theme: "vs" });}function postMessageToEditor(message) { document.getElementById('example-iframe').contentWindow .postMessage(message, "https://try.dot.net");}
3.几乎和VS一模一样的代码和错误提醒以及代码折叠功能
如下图中代码我进行了折叠
同时上面using System.Linq;命名空间我未使用到,他也给了我智能的提醒,这些都是几乎和vs一模一样的操作
最后我再附上他的Git地址:点我跳转以及他的使用教程点我跳转