Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Label class

Represents the name of a Term object in a specific language.

System.Object
  Microsoft.SharePoint.Taxonomy.Label

Namespace:  Microsoft.SharePoint.Taxonomy
Assembly:  Microsoft.SharePoint.Taxonomy (in Microsoft.SharePoint.Taxonomy.dll)

[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public sealed class Label

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.

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);
            }
        }
    }
}

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2015 Microsoft