c# error: Use of unassigned local variable (context visual studio T4 ENGINE)

Posted by user310291 on Stack Overflow See other posts from Stack Overflow or by user310291
Published on 2011-01-09T16:49:19Z Indexed on 2011/01/09 16:53 UTC
Read the original article Hit count: 148

Filed under:
|
|
|

In C# (within the context of T4 template see http://www.olegsych.com/2008/03/how-to-generate-multiple-outputs-from-single-t4-template/) I want to do this

<# String myTemplateVar; 
#>

<# if (string.IsNullOrEmpty(myTemplateVar)) { 
    myTemplateVar= "name";
}; 
#>

I want to give a value to myTemplateVar if myTemplateVar has not already been setup by an external call from T4 engine in another template which would have this instruction:

CallContext.SetData("myTemplate.myTemplateVar", ExternalTemplateVar);

But I cannot even compile in C# why ? How to fix this ?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET