情况如下:
假设我在 App_Code 中有两个文件,每个文件都包含函数块:
这是文件 AppCode/File1.cshtml 中的示例函数 #1:
@functions {
public static Boolean getTrue() {
return true;
}
}
这是文件 AppCode/File2.cshtml 中的示例函数 #2:
@functions {
public static Boolean getFalse() {
return false;
}
}
我可以通过@File1.getTrue() 或@File2.getFalse() 从我的根文件夹中引用CSHTML 文件中的任一函数。
但是,我可以在 AppCode/File1.cshtml 中调用 @File2.getFalse() 以便:
@functions {
public static Boolean getTrue() {
return (!@File2.getFalse());
}
}