---
title: "Create a list in SharePoint and Read list Data from SharePoint using C#"  
description: "In this article, I am going to explain and show you how to create a list in the SharePoint server and how to access list data in an application usi"  
author: "Chris Anderson"  
published: 2011-12-03  
updated: 2020-03-04  
canonical: https://www.mindstick.com/articles/837/create-a-list-in-sharepoint-and-read-list-data-from-sharepoint-using-c-sharp  
category: "sharepoint"  
tags: ["sharepoint"]  
reading_time: 3 minutes  

---

# Create a list in SharePoint and Read list Data from SharePoint using C#

In this article, I am going to explain and show you how to create a list in the SharePoint server and how to access list data in an [application using C#](https://www.mindstick.com/forum/160510/how-to-fetch-data-from-the-database-in-the-dot-net-console-application-using-c-sharp).\

##### To create a document library, follow these steps:

- 1) Open SharePoint 2010 Central Administration
- 2) Select More Options… option from the Site Actions menu.

![Create a list in SharePoint and Read list Data from SharePoint using C#](https://www.mindstick.com/mindstickarticle/64d0f6b6-1f1c-408d-84cd-52420c417475/images/e189d32b-f301-4df5-8db3-fb1f8fead5e7.png)

3) Prepare the custom list with the name as [Products](https://www.mindstick.com/news/2358/apple-will-use-us-made-semiconductors-in-its-products-to-lessen-its-dependency-on-asia) and click Create to create a list as shown in the below figure:

![Create a list in SharePoint and Read list Data from SharePoint using C#](https://www.mindstick.com/mindstickarticle/64d0f6b6-1f1c-408d-84cd-52420c417475/images/fb2971f0-4ab2-467b-a844-dbe1f68ce014.png)

4) After creating a list you can add items in a list by selecting Add new item option.

![Create a list in SharePoint and Read list Data from SharePoint using C#](https://www.mindstick.com/mindstickarticle/64d0f6b6-1f1c-408d-84cd-52420c417475/images/a4f1658c-a91d-4b58-ada2-1cd24e3dcb93.png)

5) But before inserting items add columns in a list. You can add columns in a list by selecting the Create Column option.

Here I am adding two columns i.e. [Product](https://yourviews.mindstick.com/view/83909/why-mindstick-platform-is-so-important-for-our-product-promotions) ID and Product Name.

![Create a list in SharePoint and Read list Data from SharePoint using C#](https://www.mindstick.com/mindstickarticle/64d0f6b6-1f1c-408d-84cd-52420c417475/images/4e3a4bea-28e6-4aae-a6b3-3cc1582c05f0.png)

6) After adding the columns add rows in a list by inserting an item.

![Create a list in SharePoint and Read list Data from SharePoint using C#](https://www.mindstick.com/mindstickarticle/64d0f6b6-1f1c-408d-84cd-52420c417475/images/be0be75b-6746-4f45-a523-5aacb3bfcac2.png)

Here I have inserted five items in a list as shown in the below figure:

![Create a list in SharePoint and Read list Data from SharePoint using C#](https://www.mindstick.com/mindstickarticle/64d0f6b6-1f1c-408d-84cd-52420c417475/images/8c918dd2-50e9-4c4b-b2c5-75edc8929e0b.png)

In the next step, we have to access a list of data in a C# application for which we have created a list in **SharePoint Server**.

**1)** Open [Visual Studio](https://www.mindstick.com/articles/12378/visual-studio-for-mac-is-out-of-beta-preview-now-officially-available) and create a Console Application.

![Create a list in SharePoint and Read list Data from SharePoint using C#](https://www.mindstick.com/mindstickarticle/64d0f6b6-1f1c-408d-84cd-52420c417475/images/f02c321f-fff4-4d73-9020-a9be84073d08.png)

2) Browse Microsoft.SharePoint.dll and it to the References.

![Create a list in SharePoint and Read list Data from SharePoint using C#](https://www.mindstick.com/mindstickarticle/64d0f6b6-1f1c-408d-84cd-52420c417475/images/09b7b889-bfaa-48f0-a0b2-e9f56a8dffd6.png)

3) In the next step, you have to change the [properties](https://yourviews.mindstick.com/view/81845/now-it-s-possible-to-predict-properties-of-any-molecule) of an application.

![Create a list in SharePoint and Read list Data from SharePoint using C#](https://www.mindstick.com/mindstickarticle/64d0f6b6-1f1c-408d-84cd-52420c417475/images/06cd5381-2be2-4023-b69a-d62c357bb87e.png)

4) In the build option change the [platform](https://www.mindstick.com/articles/13080/wikipedia-the-most-powerful-advertising-platform-of-the-digital-age) target into 64 bit (x64).

![Create a list in SharePoint and Read list Data from SharePoint using C#](https://www.mindstick.com/mindstickarticle/64d0f6b6-1f1c-408d-84cd-52420c417475/images/8ce2a1fe-2a0a-4db2-9ec1-9ad533c789a5.png)

5) Then write the below code in the [Program.cs](https://www.mindstick.com/forum/160449/how-to-get-an-ilogger-instance-without-dependency-injection-in-program-cs-during-startup) file.

```
using System;
using System.Text;
using Microsoft.SharePoint;

namespace ReadingSharePointList
{
    class Program
    {
        static void Main(string[] args)
        {
            //SPSite object
            SPSite oSpSite = new SPSite("http://rohit:34143/");

            //Connect to the web using SPWeb object
            SPWeb oSPWeb = oSpSite.OpenWeb();

            //List Object to get the list from a sharepoint site
            SPList oSpList = oSPWeb.Lists["Products"];

            //Item Collection Object getting all the items form the list
            SPListItemCollection oSpListCln = oSpList.Items;

            //iterate through all the items in itemcollection object
            foreach (SPListItem item in oSpListCln)
            {
                Console.Write(item["Product ID"] + "\t\t");
                Console.WriteLine(item["Product Name"] + "\n");
            }
        }
    }
}
```

##### Output:

![Create a list in SharePoint and Read list Data from SharePoint using C#](https://www.mindstick.com/mindstickarticle/64d0f6b6-1f1c-408d-84cd-52420c417475/images/f1f30a32-e399-4006-95ad-dfda57a64443.png)

Thanks for reading this article. I think this will help you a lot.

---

Original Source: https://www.mindstick.com/articles/837/create-a-list-in-sharepoint-and-read-list-data-from-sharepoint-using-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
