从类中调用created sub [英] calling created sub from class
本文介绍了从类中调用created sub的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好..我在类上创建一个sub并在另一个表单上调用它有问题..这是我创建的类的示例,
hi there.. i have problems on creating a sub on a class and calling it on the other form.. this is a sample on a class that i have created,
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WindowsFormsApplication1
{
class Class1
{
public void sample_sub()
{
//this is a sample sub
}
}
}
每当我在表单上调用sub时,例如form1。,如果我输入我创建的子,该子的名称不会出现..有什么解决方案吗?抱歉我的英文不好..
and whenever i call the sub on a form.. for example form1., if i type in the sub that i have created, the name of the sub wont appear.. is there any solution for this? sorry for my bad english..
推荐答案
请公开上课
Please make your class public
public class Class1
{
...
}
您还没准备好在这里提出富有成效的问题。您应该先阅读有关基础知识的内容。如果这可以为您提供一些提示,请查看此处:
You are not yet prepared to ask productive questions here. You should first read about the basics. If this can provide you with some hints, look here:
internal class SomeClass {
internal static void StaticMethod() {/* ... */}
internal void InstanceMethod() {
this.A = 5; // you can only do it in instance methods
// same as
A = 5; // but "this" can resolve name conflict and important
// for understanding of what's going on; see also below
}
//...
int A;
}
// ...
SomeClass.StaticMethod();
someInstance SomeClass = new SomeClass();
someInstance.InstanceMethod(); // the reference "someInstance" becomes "this" passed to the method
// as an implicit parameter, see above
这篇关于从类中调用created sub的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文