【问题标题】:") Expected" using t4 text templates in c#“)预期”在 c# 中使用 t4 文本模板
【发布时间】:2023-04-02 05:05:01
【问题描述】:

尝试使用 t4 文本模板在 .gbxml 文件类型和 .idf 文件类型之间进行转换 .exe,但遇到了错误。

不知何故,这段代码 sn-p 一直在告诉我: 错误 CS1026:) 预期。这发生在“相对北{deg}”)之后;'部分 我尝试放入更多括号,只是为了看看会发生什么,但错误不断发生。

这是文本模板的一部分:

<# foreach(XElement zone in doc.Element(ns+"Campus").Element(ns+"Building").Elements(ns+"Space")
{
WriteLine("Zone,");
WriteLine("    "+ zone.Element(ns+"Name").Value + ",   !- Name");
WriteLine("    0.00000,"+ "!- Direction of Relative North {deg}");
WriteLine("    0.0,                     !- X Origin {m}");
WriteLine("    0.0,                     !- Y Origin {m}");
WriteLine("    0.0,                     !- Z Origin {m}");
WriteLine("    1,                       !- Type");
WriteLine("    1.0,                     !- Multiplier");
WriteLine("    autocalculate,           !- Ceiling Height {m}");
WriteLine("    "+zone.Element(ns+"Volume").Value + ",                !- Volume {m3}");
WriteLine("    "+zone.Element(ns+"Area").Value + ";                !- Floor Area {m2}");
}#>

有人遇到过这个问题吗? 提前致谢。

编辑: 解决。我忘记了 foreach 循环末尾的 ) 。感谢您的帮助。

【问题讨论】:

  • 你不是在第一行的末尾缺少一个')'吗?看起来是这样的......
  • @user2822661 您应该将下面的答案标记为已接受。

标签: c# t4 gbxml


【解决方案1】:

你在

中打开了一个括号
foreach(

你永远不会关闭。

foreach(XElement zone in doc.Element(ns+"Campus").Element(ns+"Building").Elements(ns+"Space")  )

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-26
    • 1970-01-01
    • 2020-12-14
    • 1970-01-01
    • 2013-09-11
    • 2018-08-15
    相关资源
    最近更新 更多