如何显示C#源$ C $从外部文件c? [英] How to display C# source code from external file?
本文介绍了如何显示C#源$ C $从外部文件c?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有关我的项目,我想显示C#源$ C $ C,我从一个外部文件中获取。所有我想要做的是分析该文件,如果可能,显示code与语法高亮显示。
For my project I'd like to display C# source code that I get from an external file. All I want to do is to parse that file and if possible display the code with syntax highlighting.
如果还有可能,我想划分code我读入的各种方法。
If also possible I'd like to divide the code I read into the various methods.
应该从哪里开始呢?
推荐答案
我推荐的 AvalonEdit 。这很容易安装和使用。示例
I'd recommend AvalonEdit. It's easy to setup and use. Example
xmlns:avalonEdit="http://icsharpcode.net/sharpdevelop/avalonedit"
<avalonEdit:TextEditor Name="textEditor"
Loaded="textEditor_Loaded"
FontFamily="Consolas"
FontSize="10pt"/>
private void textEditor_Loaded(object sender, RoutedEventArgs e)
{
textEditor.Load(@"C:\MainWindow.xaml.cs");
textEditor.SyntaxHighlighting =
HighlightingManager.Instance.GetDefinition("C#");
}
示例输出
这篇关于如何显示C#源$ C $从外部文件c?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文