문제

I use the following code and I not understand the following : 1. why I don't see the definition string name inside the txt file or the for statement since this is inside the tag 2.if I want to see it do I need to use different tag?

<#
    string name = "Sop";
#>

Hello there ,<#=name #>

<# 

    for (int i = 0; i < 5; i++)
    {

        #>
        Hi!
        <#
    }
 #>

The output is

Hello there ,Sop

    Hi!
            Hi!
            Hi!
            Hi!
            Hi!
도움이 되었습니까?

해결책

Your code in between evaluation tags <# #> so that it will evaluate and run, but it won't be part of the output. If you wish to generate code, don't use the tags. More info about T4 templates as always available on MSDN. Especially this link pointing to MSDN is quite thorough about code generating from xml file storing definitions.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top