Export (0) Print
Expand All

SPUserResource.Name property

Gets the name of the user resource.

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

public string Name { get; }

Property value

Type: System.String
A string that contains the name of the resource.

The following table contains keys to the names of resources used by localizable objects in SharePoint Foundation. Note that all of the names start with an underscore character and therefore cannot be used with SPUserResource class constructors.

In addition, the SPUserCustomAction class has three named resources whose names end with well-known strings.

The following example is a console application that prints the names of user resources associated with a list.

using System;
using Microsoft.SharePoint;

namespace ConsoleApp
    class Program
        static void Main(string[] args)
            using (SPSite site = new SPSite("http://localhost"))
                using (SPWeb web = site.RootWeb)
                    SPList list = web.Lists.TryGetList("My Custom List");
                    if (list != null)
                        string formatString = "Resource name: {0}";

                        Console.WriteLine(formatString, list.DescriptionResource.Name);
                        Console.WriteLine(formatString, list.TitleResource.Name);

                        foreach (SPUserResource resource in list.UserResources)
                            Console.WriteLine(formatString, resource.Name);
            Console.Write("\nPress ENTER to continue....");

The application produces the following output to the console:

Resource name: _ListDescription
Resource name: _ListTitle

Resource name: _CTDesc0x01000F66CDF312EED545AB5D6B13978DF8FD002104CB5F4FE5474285C6FF6EE164F636
Resource name: _CTName0x01000F66CDF312EED545AB5D6B13978DF8FD002104CB5F4FE5474285C6FF6EE164F636
Resource name: _FieldDescMy_x0020_Custom_x0020_Column
Resource name: _FieldTitleMy_x0020_Custom_x0020_Column
Resource name: _ListDescription
Resource name: _ListTitle

Press ENTER to continue....
© 2014 Microsoft