hi i have a file..
and another both in the same project...
one class is being derieved form another
but the prob is : i am getting error
CsDateInheritance.exe' has more than one entry point defined: 'CsDateConstructors.Main()'
CsDateInheritance.exe' has more than one entry point defined: 'CsDateInheritance.Main()'
i have the above two files and both have main..but one is derieved from another....
why am i getting this error??
pls help...
tks...
R. Thomas
"Be anxious for nothing, but in everything by prayer and supplication, with thanksgiving, let your requests be made know to God; and the peace of God, which surpasses all understanding, will guard your hearts and minds through Christ Jesus."Philippians 4:6-7
"Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
Originally posted by Joseph_R_Thomas
i have the above two files and both have main..but one is derieved from another....
why am i getting this error??
pls help...
tks...
Hi, what I would is remove the Main() methods from both classes, then create a third class that does not inherit from anything and add a Main() method there.
Something like this:
Code:
public class CsDateConstructors
{
}
public class CsDateInheritance : CsDateConstructors
{
}
public class MyMain
{
static void Main(string[] args)
{
CsDateInheritance myInheritence = new CsDateInheritance();
}
}
i dun wanna do that...i am following a example and i am using the same exact codes...
the example runs fine/......
but mine doesnt./..
every word in the two files are same...
still mine doesnt run...
R. Thomas
"Be anxious for nothing, but in everything by prayer and supplication, with thanksgiving, let your requests be made know to God; and the peace of God, which surpasses all understanding, will guard your hearts and minds through Christ Jesus."Philippians 4:6-7
"Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
using System;
class CsDateConstructors
{
public static void Main()
{
try
{
Date mydate = new Date(2001, 8, 29);
Console.WriteLine("Day of year = " + mydate.DayOfYear);
}
catch (Exception exc)
{
Console.WriteLine(exc);
}
}
}
class Date
{
// Fields
int year;
int month;
int day;
static int[] MonthDays = new int[] { 0, 31, 59, 90, 120, 151,
181, 212, 243, 273, 304, 334 };
// Constructors
public Date()
{
Year = 1600;
Month = 1;
Day = 1;
}
public Date(int year, int month, int day)
{
if ( (month == 2 && IsLeapYear(year) && day > 29) ||
(month == 2 && !IsLeapYear(year) && day > 28) ||
((month == 4 || month == 6 ||
month == 9 || month == 11) && day > 30))
{
throw new ArgumentOutOfRangeException("Day");
}
else
{
Year = year;
Month = month;
Day = day;
}
}
// Properties
public int Year
{
set
{
if (value < 1600)
throw new ArgumentOutOfRangeException("Year");
else
year = value;
}
get
{
return year;
}
}
public int Month
{
set
{
if (value < 1 || value > 12)
throw new ArgumentOutOfRangeException("Month");
else
month = value;
}
get
{
return month;
}
}
public int Day
{
set
{
if (value < 1 || value > 31)
throw new ArgumentOutOfRangeException("Day");
else
day = value;
}
get
{
return day;
}
}
public int DayOfYear
{
get
{
return MonthDays[month - 1] + day +
(month > 2 && IsLeapYear(year) ? 1 : 0);
}
}
// Method
public static bool IsLeapYear(int year)
{
return (year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0));
}
}
Code:
using System;
class CsDateInheritance
{
public static void Main()
{
DatePlus birth = new DatePlus(1953, 2, 2);
DatePlus today = new DatePlus(2001, 8, 29);
Console.WriteLine("Birthday = {0}", birth);
Console.WriteLine("Today = " + today);
Console.WriteLine("Days since birthday = {0}", today - birth);
}
}
class DatePlus: Date
{
public DatePlus() {}
public DatePlus(int year, int month, int day): base(year, month, day) {}
public int DaysSince1600
{
get
{
return 365 * (Year - 1600) +
(Year - 1597) / 4 -
(Year - 1601) / 100 +
(Year - 1601) / 400 + DayOfYear;
}
}
public override string ToString()
{
string[] str = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
return String.Format("{0} {1} {2}", Day, str[Month - 1], Year);
}
public static int operator -(DatePlus date1, DatePlus date2)
{
return date1.DaysSince1600 - date2.DaysSince1600;
}
}
R. Thomas
"Be anxious for nothing, but in everything by prayer and supplication, with thanksgiving, let your requests be made know to God; and the peace of God, which surpasses all understanding, will guard your hearts and minds through Christ Jesus."Philippians 4:6-7
"Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
I think you want to have three projects, one containing the CsDateConstructors class, another project containing the CsDateInheritance class and a third containing the Date classes. Then to run one and not the other you simply set it as the startup project. This way all of the Main() methods are seperate
I've seperated your projects so you can see how it is done. The Date classes are compiled as a Class Library which means only a .DLL is created. The other two are compiled as Console Applications and each creates an executable (.exe). In order to use this .Dll, you need a using statement (which I have put in for you) and you need to add a reference to the .Dll for each project that will be using it. You do this by first setting a project as the startup project, then go to the Project Menu and select the Add Reference. Then select the .Dll you wan to use and select OK. I've done this for you in the attached project.
You'll get used to doing this the more you do it.
Your Date classes work very well, great job!
I hope this helps. Let me know if you have any proplems or questions.
i am not using command line
m using visual studio.net
R. Thomas
"Be anxious for nothing, but in everything by prayer and supplication, with thanksgiving, let your requests be made know to God; and the peace of God, which surpasses all understanding, will guard your hearts and minds through Christ Jesus."Philippians 4:6-7
"Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
Originally posted by mdmd
More than one main requires that you specify the startup
object.
From the DevStudio menu
Project/ "My Project" properties.
On the properties property sheet; common options. Look for
'Startup Object" and set it.
its in the same project.......
both the mains are in the same project....
just different files....
R. Thomas
"Be anxious for nothing, but in everything by prayer and supplication, with thanksgiving, let your requests be made know to God; and the peace of God, which surpasses all understanding, will guard your hearts and minds through Christ Jesus."Philippians 4:6-7
"Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
well....i think i should probably post the project...
maybe that will say better than my words...
i need to get the "Project2" working....
tks for help...
R. Thomas
"Be anxious for nothing, but in everything by prayer and supplication, with thanksgiving, let your requests be made know to God; and the peace of God, which surpasses all understanding, will guard your hearts and minds through Christ Jesus."Philippians 4:6-7
"Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
Originally posted by Joseph_R_Thomas
its in the same project.......
both the mains are in the same project....
just different files....
then the only way to do it is to comment out one of the Main methods so that the other can run. The language simply does not allow two main methods and there's nothing you can do to change that.
Originally posted by Joseph_R_Thomas
well....i think i should probably post the project...
maybe that will say better than my words...
i need to get the "Project2" working....
tks for help...
did you download the project I attached for you? I got both projects to work there.
R. Thomas
"Be anxious for nothing, but in everything by prayer and supplication, with thanksgiving, let your requests be made know to God; and the peace of God, which surpasses all understanding, will guard your hearts and minds through Christ Jesus."Philippians 4:6-7
"Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
nope...i have a version that is exactly same codes and its working fine...
there's gotta be some other trick...
R. Thomas
"Be anxious for nothing, but in everything by prayer and supplication, with thanksgiving, let your requests be made know to God; and the peace of God, which surpasses all understanding, will guard your hearts and minds through Christ Jesus."Philippians 4:6-7
"Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.