new IItemTransform [0] 。我试图谷歌搜索有关此语法的任何内容,但由于过于通用的搜索查询而没有成功。
public virtual Bundle IncludeDirectory(string directoryVirtualPath, string searchPattern, bool searchSubdirectories)
{
if (ExceptionUtil.IsPureWildcardSearchPattern(searchPattern))
throw new ArgumentException(OptimizationResources.InvalidWildcardSearchPattern, "searchPattern");
PatternType patternType = PatternHelper.GetPatternType(searchPattern);
Exception exception1 = PatternHelper.ValidatePattern(patternType, searchPattern, "virtualPaths");
if (exception1 != null)
throw exception1;
Exception exception2 = this.Items.IncludeDirectory(directoryVirtualPath, searchPattern, patternType, searchSubdirectories, new IItemTransform[0]);
if (exception2 != null)
throw exception2;
else
return this;
}
IItemTransform:
namespace System.Web.Optimization
{
public interface IItemTransform
{
string Process(string includedVirtualPath, string input);
}
}
这种感觉真的不直观,有没有人认识到语法?
答案 0 :(得分:5)
new IItemTransform[0]
只是创建一个类型为IItemTransform
的数组(大小为零)。它不会创建任何实现IItemTransform
的对象。
它在语法上与创建一个空字符串数组相同:
string[] foo;
foo = new string[0];
这只是一个IItemTransform
的数组,而不是string
。