访问对象。 [英] Accessing an object.

查看:59
本文介绍了访问对象。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。我正在尝试编写一个电影预约应用程序,我在Form1中的Movie类中创建了一个对象。 Movie类具有名称,价格,大厅和时间属性。最后,在Form4中,我想显示带有电影信息的票证,但我不能
到达该对象,因为它是在Form1中创建的。我怎么能以最后的形式到达它?在此先感谢。

解决方案

我不确定我是什么意思"在Form1中从Movie类创建一个对象"。我假设您说您正在表单中创建一个Movie类的实例。


以前有很多问题的答案与这个问题基本相同答案是相同的。


您没有说明如何创建Form4的实例。我将假设Form4实例是在Form1实例中创建的。为Form4创建一个构造函数,并将Movie类实例作为参数。然后,当Form1创建Form4时,传递Movie类
实例。


还有很多其他的可能性,但我不知道还有什么建议。


Hi. I'm trying to write a cinema reservation app and I create an object from the Movie class in Form1. The Movie class has name, price, hall and time properties. And in the end, in Form4 I want to display the ticket with the movie's information but I can't reach the object since it's created in Form1. How can I reach it in the last form? Thanks in advance.

解决方案

I am not sure I understand what you mean by "create an object from the Movie class in Form1". I will assume you are saying that you are creating an instance of the Movie class in the form.

There are very many previous answers to questions that are essentially the same as this question in the sense that the answers are the same.

You don't say how the instance of Form4 is created. I will assume that the Form4 instance is created in the Form1 instance. Create a constructor for Form4 and put the Movie class instance as a parameter. Then when Form1 creates Form4 pass the Movie class instance.

There are many other possibilities but I don't know enough to know what else to suggest.


这篇关于访问对象。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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