how to run a cs file other than program.cs in consoleappln
I created a console application with which it created program.cs file but I created different class within the same project with main method in it. How can run my new class? Every time I run my app, it keeps executing Program.cs in console application. Can you please direct me with right path?
Sunny SharmaPosted Mar 22, 2014, 6:54 AM
You may want to go through this post:
http://www.csharphelp.com/2006/08/entry-point-in-c-program/
I hope it will give you an overview of your findings.
VulpesPosted Mar 22, 2014, 10:06 AM
Geetha GubendranPosted Mar 22, 2014, 8:07 AM
Thank You All For your valuable help.
Regards,
Geetha
Geetha GubendranPosted Mar 22, 2014, 8:04 AM
but I am getting an error saying
"Error2Program 'c:\geet\projects\ConsoleApplication1\ConsoleApplication1\obj\Debug\ConsoleApplication1.exe' has more than one entry point defined: 'ConsoleApplication1.Class1.Main(string[])'. Compile with /main to specify the type that contains the entry point.C:\geet\projects\ConsoleApplication1\ConsoleApplication1\Class1.cs4328ConsoleApplication1
Error1Program 'c:\geet\projects\ConsoleApplication1\ConsoleApplication1\obj\Debug\ConsoleApplication1.exe' has more than one entry point defined: 'ConsoleApplication1.Program.Main(string[])'. Compile with /main to specify the type that contains the entry point.C:\geet\projects\ConsoleApplication1\ConsoleApplication1\Program.cs1121ConsoleApplication1
VulpesPosted Mar 22, 2014, 7:22 AM
Lakshmanan Sethu SankaranarayanPosted Mar 22, 2014, 5:49 AM
Geetha GubendranPosted Mar 22, 2014, 5:29 AM
namespace structTesting
{
public class structTestClass
{
public struct BookStruct
{
public string title;
public string category;
public string author;
public string no_of_pages;
public int currentPage;
public string ISBN;
public string coverStyle;
public BookStruct(string title, string category, string author, string no_of_pages, int currentPage, string ISBN, string coverStyle)
{
this.title = title;
this.category = category;
this.author = author;
this.no_of_pages = no_of_pages;
this.currentPage = currentPage;
this.ISBN = ISBN;
this.coverStyle = coverStyle;
}
public int prevPage(int currentPage)
{
return (currentPage - 1);
}
public int nextPage(int currentPage)
{
return (currentPage + 1);
}
}
static void main(String[] args)
{
BookStruct bookStruct = new BookStruct("KidsAffection", "kids", "Geetha", "300", 20, "125-333-1234", "HardBook");
//Output Begins
Console.WriteLine("title =>" + bookStruct.title);
Console.WriteLine("category =>" + bookStruct.category);
Console.WriteLine("author =>" + bookStruct.author);
Console.WriteLine("no_of_pages =>" + bookStruct.no_of_pages);
Console.WriteLine("currentPage =>" + bookStruct.currentPage);
Console.WriteLine("ISBN =>" + bookStruct.ISBN);
Console.WriteLine("coverStyle =>" + bookStruct.coverStyle);
Console.WriteLine("previous Page=>"+bookStruct.prevPage(20));
Console.WriteLine("next Page=>"+bookStruct.nextPage(20));
}
}
}
Sunny SharmaPosted Mar 22, 2014, 1:09 AM