C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Get the Names of all Fields in a SharePoint List
WhatsApp
Abhay Shanker
11y
43.1
k
0
0
25
Blog
Below Code block explains how to Get the Names of all fields in a SharePoint list Programmatically.
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
Microsoft.SharePoint;
namespace
SharePoint
{
class
ListFields
{
static
void
Main()
{
SPSecurity.RunWithElevatedPrivileges(
delegate
()
{
string
siteUrl =
"http://abhay-pc:1212"
;
SPSite site =
new
SPSite(siteUrl);
Console.WriteLine(site.ToString() +
"\n"
);
SPWeb web = site.OpenWeb();
SPList list = web.Lists[
"EmployeeDetails"
];
Console.WriteLine(list.ToString() +
"\n"
);
foreach
(SPField f
in
list.Fields)
{
Console.WriteLine(f.StaticName.ToString() +
" - "
+ f.TypeDisplayName.ToString() +
"\n"
);
}
});
Console.ReadLine();
}
}
}
Get the Names of all fields in a SharePoint list
Recommended related topics
Membership not found