小编use*_*846的帖子

如何在静态方法中引用非静态对象

我创建了一个文本框,想要在静态方法中引用它.我怎样才能做到这一点?在这里;我的代码

    private void Form1_Load(object sender, EventArgs e)
    {
        TextBox textbox2 = new TextBox();
        textbox2.Text = "A";
    }

    static void gettext() 
    {
        textbox2.Text = "B"; //here is my problem
    } 
Run Code Online (Sandbox Code Playgroud)

c# methods static textbox

1
推荐指数
1
解决办法
8171
查看次数

如何查找字符串中的特定字符

在c#中,如何找到字符串中的特定字符。这个“2222+2222”是我的字符串,我想在其中找到字符“+”?我想要一个如果找到则返回 bool 的函数。

c#

-6
推荐指数
1
解决办法
2万
查看次数

标签 统计

c# ×2

methods ×1

static ×1

textbox ×1