这个语法是什么,初始化一个接口,因为它是一个类数组?(新的IItemTransform [0])

 东莞家装_670 发布于 2023-02-08 09:05

在System.Web.Optimization.Bundle中找到新的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);
  }
}

这种感觉真的不直观,有没有人认识到语法?

1 个回答
  • new IItemTransform[0]只是创建一个类型的引用数组(大小为零)IItemTransform.它不会创建任何实现的对象IItemTransform.

    它在语法上与创建一个空字符串数组相同:

    string[] foo;
    foo = new string[0];
    

    它只是一个阵列而IItemTransform不是string.

    2023-02-08 09:10 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有