I am new to .NET programming using Microsoft Visual Studio .NET 2008. As I am learning by coding from my C# book, I entered this simple C# program below:
namespace
CSharpPropperty {public class Person{
Int32 age;
public Int32 Age
{ // Property
get{ return age;} set{ // validating value if (value > 0 && value < 150){age =
value;} else // throw exception{throw new ArgumentException(" Invalid age");}
}
}
}
}
Now how do I create a main() routine or testdriver (in the Solution Explorer) to test the program above in the Microsoft Visual Studio 2008 IDE?
I continue to get this error message which says:
"In order to debug this project, add an executable project to this solution which references the library project. Set the executabelproject as the startup project."
The error message is simply asking I create a main() routine but how do I do that?Need help!
Satish KathiPosted Jul 9, 2008, 1:44 PM
Change the output type of the Project to Console Application
Do do this open Properties(You can see this under project)
Select application tab and set Output Type to "Console Application"
VictorPosted Jul 9, 2008, 11:10 AM
OK,I entered that line of codeat the end of my class program (after the last "}"). However, it did not solve the problem. The error continue to say that I need to create and executable project to reference my solution project.
I think my question is how do I create the main() from the Visual Studio 2008 IDE? Do I create it as a new ".cs" project from the IDE (i.e., Start Page/New Project, and then select the Class Library Form from the Template). How will it reference my project solution? Are there file names/text I have to change on the Solution Explorer page and the Property Explorer page?
Ali ZaidiPosted Jul 9, 2008, 2:32 AM
{
static void Main(string[] args){
Person ob=new Person();
ob.Age=200;
console.writeline(ob.Age);
}
}