共用方式為


SPUserResource.Name property

會取得使用者資源名稱。

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

Syntax

'宣告
Public ReadOnly Property Name As String
    Get
'用途
Dim instance As SPUserResource
Dim value As String

value = instance.Name
public string Name { get; }

Property value

Type: System.String
包含的資源名稱的字串。

備註

下表包含機碼中SharePoint Foundation的可當地語系化物件所使用的資源的名稱。請注意所有名稱加到具有底線字元開始,因此無法搭配SPUserResource類別建構函式。

一開始名稱

使用

_CTDesc

SPContentType.DescriptionResource

_CTName

SPContentType.NameResource

_FieldDesc

SPField.DescriptionResource

_FieldTitle

SPField.TitleResource

_ListDescription

SPList.DescriptionResource

_ListTitle

SPList.TitleResource

_NavNode

SPNavigationNode.TitleResource

_WebDescription

SPWeb.DescriptionResource

_WebTitle

SPWeb.TitleResource

此外, SPUserCustomAction類別有三個具名的資源之已知的字串與其名稱結尾。

名稱結尾

使用

_CUIExtension

SPUserCustomAction.CommandUIExtensionResource

_Description

SPUserCustomAction.DescriptionResource

_Title

SPUserCustomAction.TitleResource

Examples

下列範例會列印清單相關聯的使用者資源名稱的主控台應用程式。

using System;
using Microsoft.SharePoint;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            using (SPSite site = new SPSite("https://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);
                        Console.WriteLine();

                        foreach (SPUserResource resource in list.UserResources)
                            Console.WriteLine(formatString, resource.Name);
                    }
                }
            }
            Console.Write("\nPress ENTER to continue....");
            Console.Read();
        }
    }
}
Imports System
Imports Microsoft.SharePoint

Module ConsoleApp

    Sub Main()
        Using site As New SPSite("https://localhost")
            Using web As SPWeb = site.OpenWeb()

                Dim list As SPList = web.Lists.TryGetList("My Custom List")
                If list IsNot Nothing Then
                    Dim formatString As String = "Resource name: {0}"

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

                    For Each resource As SPUserResource In list.UserResources
                        Console.WriteLine(formatString, resource.Name)
                    Next
                End If

            End Using
        End Using
        Console.Write(vbCrLf & "Press ENTER to continue....")
        Console.Read()
    End Sub

End Module

應用程式會產生下列輸出主控台:

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....

請參閱

參照

SPUserResource class

SPUserResource members

Microsoft.SharePoint namespace