与此话题相关的链接: 如何将我的类中的字符串连接到表单
我试图根据他们的答案(特别是Jeremy先生的答案)做出解决方案,但是一直出现这个错误:
'KeyWord.KeyWord.keywords' 由于其保护级别而不可访问
KeyWords.cs 的代码:
namespace KeyWord
{
public class KeyWord
{
String[] keywords = { "abstract", "as", "etc." };
}
}
主.cs的代码
// Check whether the token is a keyword.
var keyboardCls = new KeyWord.KeyWord();
String[] keywords = keyboardCls.keywords;
for (int i = 0; i < keywords.Length; i++)
{
if (keywords[i] == token)
{
// Apply alternative color and font to highlight keyword.
rtb.SelectionColor = Color.Blue;
rtb.SelectionFont = new Font("Courier New", 10, FontStyle.Bold);
break;
}
}
我应该怎么做?