方法Show()和Run()之间的区别 [英] Difference between methods Show() and Run()

查看:132
本文介绍了方法Show()和Run()之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候每个人





对于习惯于控制编程/逻辑的新手程序员来说,windows表单语法可能会变得模糊...我对面向对象编程有着非凡的知识c ++ / c#但是在winforms开发时有些事让我感到困惑..



C#



[用户定义的类]类对象/ instance = new [用户定义的类]();

类对象/ instance.Show();




Application.Run(new [user-defined class]());



//我知道Application是一个属于Microsoft .Net框架的类,Run()是类的成员函数或方法申请,但上述陈述有何不同?



我正在使用Windows窗体开发一个小规模的企业应用程序和C#



你诚挚的



哈马德

巴林

Greetings everyone


The windows form syntax may become blurry for novice programmers who are used to console programming/logic...i have an exceptional knowledge of object oriented programming c++/c# but a few things are confusing me while developing in winforms..

C#

[user-defined class] class object/instance = new [user-defined class]();
class object/instance.Show();


Application.Run(new [user-defined class]());

// i know that Application is a class that is part of the Microsoft .Net framework and Run() is a member function or method of class Application but what difference does these aforementioned statements make?

I'm developing a small scale enterprise application using windows form and C#

Yours sincerely

Hamad
Bahrain

推荐答案

首先,像所有关于差异,这个是不正确的。苹果和苹果有什么区别? :-)



然而,有趣的是,你的整个应用程序只能显示一个窗口,没有 Application.Run 和窗口关闭后退出。如果你想要那样,你实际上可以做到。但建议的方法是在需要创建完全成熟的应用程序时使用 Application.Run 。然后,您可以使用 Form.Show 来显示更多表单,或显示以前隐藏的表单。 当应用程序已经运行时就完成了。



我甚至不想研究如果你试图创建一个会发生什么可能会发生什么没有 Application.Run 的完整申请。如果一个简单的样本有效,可以尝试做更多的事情,并向您报告成就和失败。但为什么?该库不是为此类设计而设计的,并且不需要这样做。



-SA
First of all, like all questions about "differences", this one is incorrect. What is the difference between apple and Apple? :-)

Nevertheless, interestingly, your whole application can just show one window, without Application.Run and exit after the window is closed. If you want just that, you actually can do it. But the recommended way is to use Application.Run in all cases when you need to create a fully-fledged application. And then, you can use Form.Show to show some more forms, or to show a form which was previously hidden. That is done when the application is already running.

I'm not even interested to research what could happen if you try to create a full application without Application.Run. If a simple sample works, one can try to do some more and report you the achievements and failures. But why? The library is not designed for such use, and there is no a need to do such things.

—SA


这篇关于方法Show()和Run()之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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