如何从主机上调用公共课程?
因此,我正在创建一个小程序,并且很难从我的主机上召集公共课程。在主机中,如果用户选择某个选择,则应调用该类。该类在if-statement if(选择==“ 1”} {(class)} {(称为)}中。单独的类看起来像:
string actChoice = Console.ReadLine();
if (actChoice == "2")
{
class Kitchen;
}
class Kitchen
{
//this class will be played when you choose 2
public class Ren
{
//setting method
public void Meal()
so I'm creating a small program and am having trouble calling a public class from my main console. In the main console, the class is to be called if the user selects a certain choice. The class is called within an if-statement if(choice == "1"} {(class is called)}. I'll also note there's a return statement at the bottom of the second class. Here's what the first three lines of the separate class look like:
string actChoice = Console.ReadLine();
if (actChoice == "2")
{
class Kitchen;
}
class Kitchen
{
//this class will be played when you choose 2
public class Ren
{
//setting method
public void Meal()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
创建一个嵌套在另一类中的类的实例
。
Create an instance of a class nested inside another class
.
如果要使用类,则需要创建该类的新实例。
除非该类是
静态
,在这种情况下,其中的所有内容(方法字段等)也应该是静态的。例如,如何创建一个新课程:
因此,这就是您应该做的:
在课堂上观看一些视频,以及一些示例,以增强您对它们的了解。
If you want to use a class you need to create a new instance of that class.
Unless this class is
static
, and in that case everything inside it (methods fields etc..) should be static as well.How to create a new class for example:
So this is how you should do it:
Watch a few videos on classes and some example of them to strengthen your knowledge about them.