SPContentTypeId.ToString method
傳回十六進位字元的字串,表示內容類型識別碼 (ID)。
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'宣告
Public Overrides Function ToString As String
'用途
Dim instance As SPContentTypeId
Dim returnValue As String
returnValue = instance.ToString()
public override string ToString()
傳回值
Type: System.String
String,代表內容類型識別碼。前兩個字元的字串一定是"0x"。
備註
此方法所傳回的字串可以是了解遞迴性質識別碼的內容類型的有用的工具。例如,下列程式碼從清單中的內容類型,取得的內容類型識別碼,並使用該識別碼來決定適用於內容類型識別碼回三個索引產生。它具有收集所有的四個識別碼,將應用程式會在列印主控台其字串值。
SPContentTypeId child = web.Lists["Announcements"].ContentTypes["Announcement"].Id;
SPContentTypeId parent = child.Parent;
SPContentTypeId grandparent = parent.Parent;
SPContentTypeId greatgrandparent = grandparent.Parent;
Console.WriteLine("Greatgrandparent id: {0}", greatgrandparent.ToString());
Console.WriteLine(" Grandparent id: {0}", grandparent.ToString());
Console.WriteLine(" Parent id: {0}", parent.ToString());
Console.WriteLine(" Child id: {0}", child.ToString());
Dim child As SPContentTypeId = web.Lists("Announcements").ContentTypes("Announcement").Id
Dim parent As SPContentTypeId = child.Parent
Dim grandparent As SPContentTypeId = parent.Parent
Dim greatgrandparent As SPContentTypeId = grandparent.Parent
Console.WriteLine("Greatgrandparent id: {0}", greatgrandparent.ToString())
Console.WriteLine(" Grandparent id: {0}", grandparent.ToString())
Console.WriteLine(" Parent id: {0}", parent.ToString())
Console.WriteLine(" Child id: {0}", child.ToString())
這段程式碼會在列印下的輸出至主控台。
Greatgrandparent id: 0x
Grandparent id: 0x01
Parent id: 0x0104
Child id: 0x0104009010BFF57D431540B197B8058EBC3035
For more information about how content type IDs are formed, see Content Type IDs.
請參閱
參照
Microsoft.SharePoint namespace