Compartilhar via


SPRegionalSettings.FirstWeekOfYear Property

Gets or sets the first week of the year used in calendars on the server.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online

Syntax

'Declaration
Public Property FirstWeekOfYear As Short
    Get
    Set
'Usage
Dim instance As SPRegionalSettings
Dim value As Short

value = instance.FirstWeekOfYear

instance.FirstWeekOfYear = value
public short FirstWeekOfYear { get; set; }

Property Value

Type: System.Int16
A 16-bit integer that specifies the first week of the year.

Remarks

The FirstWeekOfYear property throws an exception if the value is not between 0 and 2.

Examples

The following code example sets the first week of the year to be the first full week of the year.

Dim siteCollection As New SPSite("https://localhost")
Try
    Dim rootWebSite As SPWeb = siteCollection.RootWeb
    Dim regionalsettings As SPRegionalSettings = rootWebSite.RegionalSettings
    regionalsettings.FirstWeekOfYear = 1

    rootWebSite.Update()
    rootWebSite.Dispose()
Finally
    siteCollection.Dispose()
End Try
using (SPSite oSiteCollection = new SPSite("https://localhost"))
{
    using (SPWeb oWebsiteRoot = oSiteCollection.RootWeb)
    {
        SPRegionalSettings oRegionalSettings = oWebsiteRoot.RegionalSettings;
        oRegionalSettings.FirstWeekOfYear = 1;
        oWebsiteRoot.Update();
    }
}

Note

Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Disposing Objects.

See Also

Reference

SPRegionalSettings Class

SPRegionalSettings Members

Microsoft.SharePoint Namespace