SPFieldLink.Name 属性

获取字段引用对象的内部名称。

命名空间:  Microsoft.SharePoint
程序集:  Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)

语法

声明
Public ReadOnly Property Name As String
    Get
用法
Dim instance As SPFieldLink
Dim value As String

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

属性值

类型:System.String
对象的内部名称。

备注

此属性的值等同于作为参数传递给SPFieldLink构造函数的SPField对象InternalName属性的值。

示例

下面的示例演示一个循环字段和字段的内容类型的链接集,然后打印InternalName属性为每个字段的值和相应的字段链接到控制台的Name属性值的控制台应用程序。

Imports System
Imports Microsoft.SharePoint

Module ConsoleApp
    Sub Main()
        Dim site As SPSite = New SPSite("https://localhost")
        Try
            Dim web As SPWeb = site.OpenWeb()
            Try
                Dim ctName As String = "Announcement"
                Dim contentType As SPContentType = web.ContentTypes(ctName)
                If contentType IsNot Nothing Then
                    For i As Integer = 0 To contentType.Fields.Count - 1
                        Console.WriteLine("Field.InternalName = {0}", contentType.Fields(i).InternalName)
                        Console.WriteLine("FieldLink.Name = {0}", contentType.FieldLinks(i).Name)
                        Console.WriteLine()
                    Next
                End If
            Finally
                web.Dispose()
            End Try
        Finally
            site.Dispose()
        End Try
        Console.Write("Press ENTER to continue...")
        Console.ReadLine()
    End Sub
End Module
using System;
using Microsoft.SharePoint;

namespace Test
{
    class ConsoleApp
    {
        static void Main(string[] args)
        {
            using (SPSite site = new SPSite("https://localhost"))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    string ctName = "Announcement";
                    SPContentType contentType = web.ContentTypes[ctName];
                    if (contentType != null)
                    {
                        for (int i = 0; i < contentType.Fields.Count; i++)
                        {
                            Console.WriteLine("Field.InternalName = {0}", contentType.Fields[i].InternalName);
                            Console.WriteLine("FieldLink.Name = {0}", contentType.FieldLinks[i].Name);
                            Console.WriteLine();
                        }
                    }
                }
            }
            Console.Write("Press ENTER to continue...");
            Console.ReadLine();
        }
    }
}

应用程序将以下输出显示到控制台上。

Field.InternalName = ContentType
FieldLink.Name = ContentType

Field.InternalName = Title
FieldLink.Name = Title

Field.InternalName = Body
FieldLink.Name = Body

Field.InternalName = Expires
FieldLink.Name = Expires

Press ENTER to continue...

另请参阅

引用

SPFieldLink 类

SPFieldLink 成员

Microsoft.SharePoint 命名空间

SPFieldLink(SPField)

其他资源

Fields and Field References

Introduction to Columns

Introduction to Content Types