单身类属性 [英] Singleton Class Property

查看:119
本文介绍了单身类属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有这段代码。



Hi,

I have this code down.

string check = textbox1.Text;

if (duplicate.Contains(check) == true)
{
    int remove = Math.Max(0, final.Count - 25);
    final.RemoveRange(0, remove);

    int delete = Math.Max(0, duplicate.Count - 5);
    duplicate.RemoveRange(5, delete);

    duplicate.Add(check);

    duplicate.AddRange(final);
}





此代码属于一个类,我使用的是Singleton。我还是新手。我被困在代码中



string check = textbox1.Text;



它显示textbox1没有目前的情况不存在。



需要帮助。



提前致谢。



This code is in a class and I'm using Singleton. I am still new to this. I was stuck in the code

string check = textbox1.Text;

It shows that textbox1 doesn't exists in the current context.

Help needed.

Thanks in advance.

推荐答案

由于错误消息告诉您无法从您要访问它的位置访问textbox1 。它既不是包含类 WordCloudHelper 的字段或属性,也不是方法 GetWordCloud 的参数。



我认为你必须传入检查作为String参数(从textbox1.text分配到textbox1。文本可访问)。
As the error message tells you textbox1 is not accessible from where you want to access it. It is neither a field or property of the containing class WordCloudHelper, nor a parameter to the method GetWordCloud.

I think you have to pass in check as String parameter (assigned from textbox1.text somewhere where textbox1.text is accessible).


这篇关于单身类属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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