我有一种感觉,我会得到很多关于"你N000B"的评论.
我有这门课:
public partial class FindAndReplace : Form
{
public FindAndReplace()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
}
}
Run Code Online (Sandbox Code Playgroud)
我希望能够做这样的事情来存储在其他函数中使用的引用:
public partial class FindAndReplace : Form
{
SomeRefType m_TabRef; // Dont know what type to use
public FindAndReplace(ref TabControl launguageTabs)
{
InitializeComponent();
m_TabRef = languageTab;
}
private void button1_Click(object sender, EventArgs e)
{
// use m_TabRef here that will change the original I passed in
}
}
Run Code Online (Sandbox Code Playgroud)
一种解决方法是使用TabControl的副本并返回我想要标记的位置.我只是想知道我是否可以使用原件.
如果人们谷歌也可以认为这篇文章可能会有用.
如果这是C++就很容易:/
由于TabControl已经是引用类型,您可以简单地使用它:
TabControl m_TabRef;
public FindAndReplace(TabControl launguageTabs)
{
m_TabRef = languageTab;
// from now m_TabRef references the object instance
// passed as launguageTabs reference
}
Run Code Online (Sandbox Code Playgroud)