SPFieldLink.Id property
取得識別欄位參照的 GUID。
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'宣告
Public ReadOnly Property Id As Guid
Get
'用途
Dim instance As SPFieldLink
Dim value As Guid
value = instance.Id
public Guid Id { get; }
Property value
Type: System.Guid
欄位參照的唯一識別碼。
備註
此屬性的值是Id屬性會對應至欄位參照之欄位的值相同。您可以使用此屬性值為索引,到的內容類型SPFieldCollection屬性,以及其SPFieldLinkCollection屬性。
Examples
下列範例會顯示主控台應用程式,逐一SPFieldCollection的內容類型,並列印SPField.Id屬性的值以及主控台相對應的SPFieldLink.Id屬性的值。
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 contentType As SPContentType = web.ContentTypes("Item")
For Each field As SPField In contentType.Fields
Dim link As SPFieldLink = contentType.FieldLinks(field.Id)
Console.WriteLine("Field.Id = {0}", field.Id)
Console.WriteLine("FieldLink.Id = {0}", link.Id)
Console.WriteLine()
Next field
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())
{
SPContentType contentType = web.ContentTypes["Item"];
foreach (SPField field in contentType.Fields)
{
SPFieldLink link = contentType.FieldLinks[field.Id];
Console.WriteLine("SPField.Id = {0}", field.Id);
Console.WriteLine("SPFieldLink.Id = {0}", link.Id);
Console.WriteLine();
}
}
}
Console.Write("Press ENTER to continue...");
Console.ReadLine();
}
}
}
應用程式會在列印下列輸出至主控台。
Field.Id = c042a256-787d-4a6f-8a8a-cf6ab767f12d
FieldLink.Id = c042a256-787d-4a6f-8a8a-cf6ab767f12d
Field.Id = fa564e0f-0c70-4ab9-b863-0177e6ddd247
FieldLink.Id = fa564e0f-0c70-4ab9-b863-0177e6ddd247
Press ENTER to continue...
請參閱
參照
Microsoft.SharePoint namespace