473,465 Members | 1,419 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

The type or namespace name 'Date' could not be found

When building a C# project in VS (compacted code included here), I get the
following error message.
What does it mean, and what should I do to overcome the problem?

Error Messge:

C:\USR\Dev\C#\DateInheritance.cs(15): The type or namespace name 'Date'
could not be found (are you missing a using directive or an assembly
reference?)

Thanks,
Victor

=================================

using System ;

class DateInheritance
{
public static void Main()
{ ...}
}
class DatePlus : Date <---------- Problematic line
{ public DatePlus() {}
public DatePlus(int year, int month, int day): base(year, month, day) {}
public int DaysSince1600
{ ... } // properties
public override string ToString()
{ ... }
public static int operator -(DatePlus date1, DatePlus date2)
{ ... }
}
Nov 16 '05 #1
6 14253
Make sure that the correct assembly is referenced and that you import the
correct namespace.

"Victor" <vm****************************@earthlink.net> wrote in message
news:Pr*****************@newsread3.news.atl.earthl ink.net...
When building a C# project in VS (compacted code included here), I get the
following error message.
What does it mean, and what should I do to overcome the problem?

Error Messge:

C:\USR\Dev\C#\DateInheritance.cs(15): The type or namespace name 'Date'
could not be found (are you missing a using directive or an assembly
reference?)

Thanks,
Victor

=================================

using System ;

class DateInheritance
{
public static void Main()
{ ...}
}
class DatePlus : Date <---------- Problematic line
{ public DatePlus() {}
public DatePlus(int year, int month, int day): base(year, month, day) {} public int DaysSince1600
{ ... } // properties
public override string ToString()
{ ... }
public static int operator -(DatePlus date1, DatePlus date2)
{ ... }
}

Nov 16 '05 #2
Victor <vm****************************@earthlink.net> wrote:
When building a C# project in VS (compacted code included here), I get the
following error message.
What does it mean, and what should I do to overcome the problem?


Well, what class are you trying to derive from? There is no Date class
as far as I know.

If you meant DateTime, should should realise that that's a struct, so
you can't derive from it.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #3
Thank you, Peter.
How do I do that?

Victor
Make sure that the correct assembly is referenced and that you import the
correct namespace.
"Victor" <vm****************************@earthlink.net> wrote in message
news:Pr*****************@newsread3.news.atl.earthl ink.net...
When building a C# project in VS (compacted code included here), I get the following error message.
What does it mean, and what should I do to overcome the problem?

Error Messge:

C:\USR\Dev\C#\DateInheritance.cs(15): The type or namespace name 'Date'
could not be found (are you missing a using directive or an assembly
reference?)

Thanks,
Victor

=================================

using System ;

class DateInheritance
{
public static void Main()
{ ...}
}
class DatePlus : Date <---------- Problematic line
{ public DatePlus() {}
public DatePlus(int year, int month, int day): base(year, month,
day) {}
public int DaysSince1600
{ ... } // properties
public override string ToString()
{ ... }
public static int operator -(DatePlus date1, DatePlus date2)
{ ... }
}


Nov 16 '05 #4
Victor <vm****************************@earthlink.net> wrote:
Thank you, Peter.
How do I do that?


Assuming you're using VS.NET, you add a reference to an assembly by
right-clicking on the "References" item in the project.

You tell the compiler you wish to use a specific namespace by putting

using TheNamespaceIWant;

at the top of your source code.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #5
Thank you, Jon.

I am following Charles Petzold's book "Programming Microsoft Windows with
C#", page 41.

Also, I have successfully used Date as type for variables definitions.
What I cannot understand is why is it that I cannot inherit from it in this
specific code sample.

I guess if he wrote code using the Date class, he knows what's he talking
about.
In addition to that, when I try DateTime I get the following error:

C:\USR\Dev\C#\DateInheritance.cs(15): 'DatePlus' : cannot inherit from
sealed class 'System.DateTime'

Victor
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Victor <vm****************************@earthlink.net> wrote:
When building a C# project in VS (compacted code included here), I get the following error message.
What does it mean, and what should I do to overcome the problem?


Well, what class are you trying to derive from? There is no Date class
as far as I know.

If you meant DateTime, should should realise that that's a struct, so
you can't derive from it.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #6
Victor <vm****************************@earthlink.net> wrote:
Thank you, Jon.

I am following Charles Petzold's book "Programming Microsoft Windows with
C#", page 41.
Unfortunately, my copy of that book is at work.
Also, I have successfully used Date as type for variables definitions.
I seriously doubt that, unless you've defined Date in the same project
- which Petzold may well have done.

Could you post a short but complete program which demonstrates using
the Date class, and which compiles without you also including the Date
class itself?
What I cannot understand is why is it that I cannot inherit from it in this
specific code sample.

I guess if he wrote code using the Date class, he knows what's he talking
about.
Unfortunately, in my experience code in books often doesn't compile.
Alternatively, as suggested above, he's included his own Date class.
Date is most definitely *not* a type in the main framework though.
In addition to that, when I try DateTime I get the following error:
C:\USR\Dev\C#\DateInheritance.cs(15): 'DatePlus' : cannot inherit from
sealed class 'System.DateTime'


Yes, because as I said, DateTime is a struct, so you can't derive from
it.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: | last post by:
Source Error: Line 173: sData(rownumber - 1, lcnt) = WhatCol.Value Line 174: End IF Line 175: If (sData(rownumber, lcnt) = sData(rownumber - 1, lcnt)) AND...
1
by: Randall Parker | last post by:
Using VS 2003 and Cassini web server. I'm new to ASP.Net and so this may be a dumb question. I'm getting an error where the type 'FarmLand.WebForm1' is not found. The Codebehind C# source file...
7
by: John Grandy | last post by:
My ASP.NET Web Service project has a Web Method that returns an array filled with instances of a custom class. The custom class is defined in a Class Library that is included in the web-service...
1
by: Marc | last post by:
Hi! I'm working with a C# client that calls a php web service. I've created a wrapper to call the service using .NET wsdl tool (adding a web reference). The call to the server works fine, it...
7
by: Nalaka | last post by:
Hi, I created a sinple web service that returns a dataSet. Then I created a client program that uses this web service (that returns the Dataset). My question is, how did the client figure...
0
by: DC | last post by:
Why would this code give me the error "Could not load type System.Web.UI.WebControls.AccessDataSource from assembly System.Web, Version=1.0.5000.0" at line 16... <form id="form1"...
6
by: antonyliu2002 | last post by:
Hi, guys, I am using Visual Web Developer Express 2005 for my web application. I wrote a simple class called MyTestClass.cs and put it in the App_Code folder. I compiled it to library from...
3
by: BombDrop | last post by:
Can any one help I have a method that will return a List to be bound as a datasource to a combobox see code for population below. I get the following error when i try to compile Error 29 ...
5
by: mknoll217 | last post by:
I am a newbie at XML. I have been given an xml document that I need to write the schema for, for a class assignment. The xml given to me is <?xml version="1.0"?> <Vendors> <Vendor> ...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.