Question

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!
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top