需要在控制台应用程序中设置另一个类文件。 [英] Need to set start up another class file in console application.

查看:75
本文介绍了需要在控制台应用程序中设置另一个类文件。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,



我正在使用控制台应用程序在OOPS中尝试一些基本概念。

我有两个类,即program.cs和Abstractsample.cs。

最初Program.cs有一个项目的入口点,即启动项目。

现在我想更改应用程序需要的项目的入口点启动Abstractsample.cs。

我在每个类中都有main()函数,但是我无法使它运行。

所以请在这方面帮助我。



问候,

RK

Hi Friends,

Am trying some basic concepts in OOPS using console application.
I have two classes namely program.cs and Abstractsample.cs.
Initially Program.cs is having a entry point to the project, that is start up project.
Now I want to change the entry point for the project that is application needs to start up with Abstractsample.cs.
I do have main() function in each classes, but I could not make it run.
So please help me in this regards.

Regards,
RK

推荐答案

如下所示:

Something like the following:
// Abstractsample.cs
namespace ooptest
{
    class abstractsample
    {
        static void Main(string[] args)
        {
            Program pgm = new Program();
            pgm.execute()
        }

    }
}        
// Program.cs
namespace ooptest
{
    public class program
    {
        public program()
        {
            // add constructor code here
        }

        public void execute()
        {
            // add this method's code here
        }
    }
}        


在两个类之一中有main()函数。当您创建 NEW PROJECT 并且在完成所有要求后,您的项目已准备好创建程序,并不是在
Have main() function in one of the two classes. Not in both


when you create a NEW PROJECT and after all the filling the all requirement your project is ready for creating programs okay.Instead of writing code in Default page ie Program.cs you have to ADD NEW ITEM and selectClass.(i use MyProgram.cs)
After naming it you start (MyProgram.cs) write code in it .Click on Project Menu and click on Set as startup page  Press F5 for Debugging code .Click on Project properties i mean click on last option on Project menu Then a Window is open Select ASSEMBLY CLLICK ON STATUP OBJECT i select i select  C_SHARP_CONSOLE.MyProgram now my statup page i mean MyProgram.cs is started executing


这篇关于需要在控制台应用程序中设置另一个类文件。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆