在文本格式化C#代码? [英] Formatting C# code in text?

查看:179
本文介绍了在文本格式化C#代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您在这个编辑器,我在现在写作,当你按下Ctrl + K和再粘贴代码,并保存它注意到,它将成为格式化就像是在Visual Studio中。

If you notice in this very editor that I am writing in right now, when you press "ctrl + k" and the then paste your code and save it, it will become formatted like it was in visual studio.

现在我想要做我自己使用的程序WinForms和我想查看我的代码保存的片段,并相应地格式化。任何帮助表示赞赏。

Now I want to do my own program using winforms and I would like to view the snippets of codes I save and format it accordingly. Any help is appreciated.

推荐答案

有关我的博客我用马诺利的C#格式化。

For my blog I use Manoli's C# formatter.

http://www.manoli.net/csharpformat/

格式化的源代码可以在这里找到:

The source code of the formatter is available here:

http://www.manoli.net/csharpformat/CSharpFormat.zip

基本上,你收集所有的关键字,编译器指令...等。并使用正则表达式来找到它们。于是笔者包装HTML标签身边来格式化文本。

Basically you collect all the keywords, compiler directives...etc. and use regular expressions to find them. Then the author wraps HTML tags around them to format the text.

您可以按照同样的方法,包括你自己的格式是兼容任何的WinForms控制您要使用

You could follow the same approach and include your own formatting which is compatible with whichever WinForms control you want to use.

这篇关于在文本格式化C#代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆