阅读Code Generation and T4 Text Templates我发现这个语法 <#= DateTime.Now #>
<html><body>
The date and time now is: <#= DateTime.Now #>
</body></html>
与 <%= DateTime.Now %>
有什么不同或<%# DateTime.Now %>
。
谷歌搜索没有显示任何内容
最佳答案
我不能声称自己真正熟悉 T4 文本模板,但似乎区别在于设计/构建时代码生成(可以包括可执行语句)和运行时代码执行之间。
所以<#= #>
计算用于生成文件的模板内的表达式。
和<%= %>
执行 block 内的代码并将其写入输出流。这将在页面首次执行时进行 JIT 编译,但重点是它表示在页面运行时执行的代码块,而不是在生成模板文件期间执行。
第三种形式,<%# %>
表示数据绑定(bind)表达式,也在页面执行时进行计算。
Expression control blocks
An expression control block evaluates an expression and converts it to a string. This is inserted into the output file.
Expression control blocks are delimted by the symbols <#= ... #>
For example, the following control block causes the output file to contain "5":
<#= 2 + 3 #>
关于asp.net - <#=#>是什么意思,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11874802/