c# equivalent for this DatePart("w", Now())

Posted on 2009-02-18
Last Modified: 2012-08-13

What is the equivalent C# for this vb code snippets:

DatePart("w", Now())
Question by:ube100
    LVL 22

    Expert Comment

    LVL 22

    Expert Comment

    is that to get the weekday?
    LVL 142

    Expert Comment

    by:Guy Hengel [angelIII / a3]
    are you looking for the DateOfWeek property?

    Author Comment

    P Davis,

    This is giving day of the week i.e. Thursday But I want the number for the particular day, for example if sunday that should retrun 1 , Monday should return 2 and so forth. Which what above VB function is doing and I don't know this is available in C#.
    LVL 22

    Expert Comment

    Int32 i =(int) DateTime.Now.DayOfWeek;
    LVL 22

    Accepted Solution

    but with this monday is 1 and sunday is 7

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Article by: Ivo
    Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now