I have the following C# code:
using (SPSite site = new SPSite("http://mysharepointsiteurl")
{
using (SPWeb web = site.OpenWeb())
{
SPListItemCollection itemCollection = web.Lists["List Name"].Items;
foreach (SPListItem item in itemCollection)
{
Console.WriteLine(item["Field Name"]);
// prints 5 different results.
}
web.Dispose();
}
site.Dispose();
Is there anyway I can get, say the 4th printed out result, and store it in a string? I'm sure there is a way but I can't seem to work it out. Thanks for any help! :)
You can use the indexer to get the item at a given position: