SPContentTypeId.ToString 方法
返回表示内容类型标识符 (ID) 的十六进制字符串。
命名空间: Microsoft.SharePoint
程序集: Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)
语法
声明
Public Overrides Function ToString As String
用法
Dim instance As SPContentTypeId
Dim returnValue As String
returnValue = instance.ToString()
public override string ToString()
返回值
类型:System.String
一个字符串,表示内容类型 id。前两个字符的始终是字符串的"0 x"。
备注
此方法返回的字符串可以是用于了解的内容类型 Id 递归性质的有用工具。例如,下面的代码从列表内容类型,获取的内容类型 ID,并使用该 ID 来确定三代后的内容类型的 Id。当它收集所有四个 Id 时,该应用程序打印到控制台其字符串值。
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.