如何在一个班级中调用一个班级.CS-CS# [英] How do i call one class.CS in another class.CS- C#

查看:345
本文介绍了如何在一个班级中调用一个班级.CS-CS#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个类名称PersonalInfo.CS.我想将此类称为另一个类,例如EmplInfoc.​​cs

I create one class name PersonalInfo.CS. i want to call this class to another class like EmplInfoc.cs

推荐答案

//Creating object to the class
ClassName obj = new ClassName ();

//accessing function inside the ClassName 
 obj.GenerateTable("select * from table");


相同的问题 [
The same question[^] was asked by another person before.
Is he your friend or colleague?


重新发布问题的答案
---
您需要在EmplInfoc中创建PersonalInfo的实例,您可以使用new关键字来实现.例如
Reposted answer to the reposted question
---
you need to create an instance of PersonalInfo in your EmplInfoc you do that by using the new keyword. E.g.
PersonalInfo personalInfo = new PersonalInfo();
personalInfo.APublicMethod();



但是,这是非常基础的,因此我认为您在这里不会获得满意的答案,因为对基础的解释要比对几行的解释要多.我建议您去书店找一本书.



This is very basic however, so I don''t feel you will get satisfying answers here as explaining the basics takes a bit more then a few lines of explanation. I suggest you go to a bookstore and find yourself a book.


这篇关于如何在一个班级中调用一个班级.CS-CS#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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