SPFieldLink.Name property

Gets the internal name of the field reference object.

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

public string Name { get; }

Property value

Type: System.String
The internal name of the object.

The value of this property is identical to the value of the InternalName property of the SPField object that is passed as an argument to the SPFieldLink constructor.

The following example shows a console application that iterates through the field and field link collections of a content type, and then prints the value of the InternalName property for each field and the value of the Name property for the corresponding field link to the console.

using System;
using Microsoft.SharePoint;

namespace Test
{
    class ConsoleApp
    {
        static void Main(string[] args)
        {
            using (SPSite site = new SPSite("http://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();
        }
    }
}

The application prints the following output to the console.

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