TagCollection

TagCollection 类

表示标签的集合(用户定义的字符串对)

public sealed class TagCollection : ITagCollection

属性

名称描述
Count { get; }返回集合中标签的数量。只读 Int32。
IsSynchronized { get; }返回一个值,指示访问集合是否是同步的(线程安全)。只读 Boolean。
Item { get; set; }返回或设置标签的键和值对。
SyncRoot { get; }返回同步根。只读 Object。

方法

名称描述
Add(string, string)向集合中添加一个新标签。
Clear()从集合中删除所有标签。
Contains(string)确定集合是否包含特定名称。
CopyTo(Array, int)将集合中的所有元素复制到指定的数组中。
GetEnumerator()返回一个枚举器,该枚举器遍历集合。
GetNameByIndex(int)返回指定索引处标签的键。
GetNamesOfTags()返回标签的名称。
GetValueByIndex(int)返回指定索引处标签的值。
IndexOfName(string)返回集合中指定键的零基索引。
Remove(string)从集合中删除具有指定名称的标签。
RemoveAt(int)移除指定索引处的标签。

示例

以下示例演示如何向 PowerPoint 演示文稿添加标签。

[C#]
using (Presentation pres = new Presentation("pres.pptx"))
{
   ITagCollection tags = pres.CustomData.Tags;
   pres.CustomData.Tags["MyTag"] = "My Tag Value";
}

另请参见