如何逃避和>在< pre>标签 [英] How to escape < and > inside <pre> tags

查看:157
本文介绍了如何逃避和>在< pre>标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试撰写一篇博客文章,其中包含< pre> 标签中的代码段。代码段包括通用类型,并使用<> 来定义该类型。这是片段的样子:

I'm trying to write a blog post which includes a code segment inside a <pre> tag. The code segment includes a generic type and uses <> to define that type. This is what the segment looks like:

<pre>
    PrimeCalc calc = new PrimeCalc();
    Func<int, int> del = calc.GetNextPrime;
</pre>

生成的HTML将删除<> 并结束如下:

The resulting HTML removes the <> and ends up like this:

PrimeCalc calc = new PrimeCalc();
Func del = calc.GetNextPrime;

我如何逃避<> 所以它们显示在HTML中?

How do I escape the <> so they show up in the HTML?

推荐答案

<pre>
    PrimeCalc calc = new PrimeCalc();
    Func&lt;int, int&gt; del = calc.GetNextPrime;
</pre>

这篇关于如何逃避和&gt;在&lt; pre&gt;标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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