Label Class
Represents the name of a Term object in a specific language.
Inheritance Hierarchy
System.Object
Microsoft.SharePoint.Taxonomy.Label
Namespace: Microsoft.SharePoint.Taxonomy
Assembly: Microsoft.SharePoint.Taxonomy (in Microsoft.SharePoint.Taxonomy.dll)
Syntax
'Declaration
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
Public NotInheritable Class Label
'Usage
Dim instance As Label
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public sealed class Label
Remarks
Aterm can have one or more labels in the default language, and zero or more labels in the non-default language. If the term has labels in a language, one of the labels must be the default label.
Examples
using System;
using System.IO;
using System.Globalization;
using System.Collections.Specialized;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Taxonomy;
namespace Microsoft.SDK.SharePointServer.Samples
{
public static class LabelSamples
{
public static void UseLabel(TermStore store, Term term, string newLabel)
{
// Show all the labels in current language
DisplayLabels(term);
Console.WriteLine("Adding a new label");
// Create a new label
Label label = term.CreateLabel(newLabel,
CultureInfo.CurrentUICulture.LCID,
false);
// Commit the change into the TermStore
store.CommitAll();
// Show all the labels in current language
DisplayLabels(term);
// Set the new label as the default label for current language
label.SetAsDefaultForLanguage();
// Commit the change into the TermStore
store.CommitAll();
// Show all the labels in current language
DisplayLabels(term);
}
public static void DisplayLabels(Term term)
{
// Show all the labels in current language
foreach (Label termLabel in term.Labels)
{
Console.WriteLine("The term has label: \"" + termLabel.Value
+ "\" and IsDefault is " + termLabel.IsDefaultForLanguage);
}
}
}
}
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.