Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7928113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:39:02+00:00 2026-06-03T19:39:02+00:00

This is the updated version of my C# class where I am getting the

  • 0

This is the updated version of my C# class where I am getting the message:

Unreachable code detected : DateTime.Now.Ticks;

Everything else seems to be ok. Where is my mistake?

using System;
using System.Globalization;

namespace domain
{
    public class Request : Unique
    {
        private DateTime dateBooked_Renamed;

        private DateTime dateSignedIn ;

        private DateTime dateSignedOut ;

        private bool arrived_Renamed = false;

        private bool paid_Renamed = false;

        private Hotel hotel_Renamed;

        private Employee employee_Renamed;

        private int numberOfNights;

        public Request(Hotel hotel, Employee employee, string dateBooked, string dateArrived, int numberOfNights)
            : base()
        {
            this.hotel_Renamed = hotel;
            this.employee_Renamed = employee;
            this.numberOfNights = numberOfNights;
            try
            {
                DateTime.ParseExact(dateBooked, "dd/MM/yyyy", CultureInfo.InvariantCulture);

                this.dateBooked_Renamed = DateTime.ParseExact(dateBooked, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                this.dateSignedIn = DateTime.ParseExact(dateArrived, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            }
            catch (FormatException e)
            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
            }
        }

        public virtual bool checkout(double money, string date)
        {
            try
            {
                dateCheckedOut = DateTime.ParseExact(date, "dd/MM/yyyy", CultureInfo.InvariantCulture);

            }
            catch (FormatException e)
            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
            }
            if (money >= price())
            {
                paid = true;
            }
            else
            {
                paid = false;
            }
            return paid_Renamed;
        }

        public virtual int days()
        {
            long tNow = dateSignedOut != null ? dateSignedOut.Ticks : DateTime.Now.Ticks; 
            long tThen = arrived ? dateArrived.Ticks : tNow;
            long diff = tNow - tThen;

            long secondInMillis = 1000;
            long minuteInMillis = secondInMillis * 60;
            long hourInMillis = minuteInMillis * 60;
            long dayInMillis = hourInMillis * 24;
            long yearInMillis = dayInMillis * 365;

            diff = diff % yearInMillis;
            long elapsedDays = diff / dayInMillis;

            return (int)elapsedDays;
        }

        public virtual Hotel hotel
        {
            get
            {
                return hotel_Renamed;
            }
            set
            {
                this.hotel_Renamed = value;
            }
        }

        public virtual DateTime dateArrived
        {
            get
            {
                return dateSignedIn;
            }
            set
            {
                this.dateSignedIn = value;
            }
        }

        public virtual DateTime dateBooked
        {
            get
            {
                return dateBooked_Renamed;
            }
            set
            {
                this.dateBooked_Renamed = value;
            }
        }

        public virtual DateTime dateCheckedOut
        {
            get
            {
                return dateSignedOut;
            }
            set
            {
                this.dateSignedOut = value;
            }
        }

        public virtual Employee employee
        {
            get
            {
                return employee_Renamed;
            }
            set
            {
                this.employee_Renamed = value;
            }
        }

        public virtual bool arrived
        {
            get
            {
                return arrived_Renamed;
            }
            set
            {
                this.arrived_Renamed = value;
            }
        }

        public virtual bool paid
        {
            get
            {
                return paid_Renamed;
            }
            set
            {
                this.paid_Renamed = value;
            }
        }

        public virtual double price()
        {
            // The total cost of the stay...

            double price = days() * employee_Renamed.type.price;
            if (hotel_Renamed.premium)
            {
                return price - (0.2 * price);
            }
            else
            {
                return price;
            }
        }



        public virtual bool hasArrivalDate(string date)
        {
            try
            {
                DateTime d = DateTime.ParseExact(date, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                Console.WriteLine("Comparing " + d + " with " + dateSignedIn + " = " + dateSignedIn.ToString("dd/MM/yyyy").Equals(d.ToString("dd/MM/yyyy")));
                return dateSignedIn.ToString().Equals(d.ToString());
            }
            catch (FormatException e)
            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
                return false;
            }
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T19:39:04+00:00Added an answer on June 3, 2026 at 7:39 pm

    If your date string in standard form, you can use DateTime.Parse(date)
    If not, you can use DateTime.ParseExact(date,"your custom format",CultureInfo.InvariantCulture)

    As a sample from your code

    public virtual bool hasArrivalDate(string date)
            {
                try
                {
                    DateTime d = DateTime.ParseExact(date,"dd/MM/yyyy",CultureInfo.InvariantCulture);
                    Console.WriteLine("Comparing " + d.ToString("dd/MM/yyyy") + " with " + dateSignedIn.ToString("dd/MM/yyyy") + " = " + dateSignedIn.ToString("dd/MM/yyyy").Equals(d.ToString("dd/MM/yyyy")));
                    return dateSignedIn.ToString().Equals(d.ToString());
                }
                catch (FormatException e)
                {
                    Console.WriteLine(e.ToString());
                    Console.Write(e.StackTrace);
                    return false;
                }
            }
    

    So, it’s no need instance of DateFormat

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have updated my symfony version to 2.0.12 version. But I have this error
Here's a simplified version of my code that compiles: #include <iostream> class pos {
This is getting extremely irritating. Right now I have a winforms application, and things
I've upgraded my bootstrap version to 2.0.2 and with this update the design of
Update: I updated this after doing some digging and realizing that this might be
-- This is an updated post, old post removed -- Suppose I have data
Updated Question: $(this).attr(EmployeeId, 'A42345'); $.ajax({ type: POST, url: url, data: {EmployeeId: ' + id
N.B THIS QUESTION HAS BEEN UPDATED, READ FURTHER DOWN Hi, I want to create
I have a table of frequently updated information. This is presented using a container
I little while back I posted this question . I have updated that question

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.