I've been working on this stringcodes in program:
string[] keywords = { "abstract", "as", "etc" };
and its working the time i use it after this code (in mainform.cs):
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;
}
}
but thing is i want to make separate class (KeyWord.cs) for keywords and declare it in mainform but this code not working:
KeyWord.cs:
namespace editor
{
class KeyWord
{
string[] keywords = { "abstract", "as", "etc" };
}
}
Mainform.cs:
string[] 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;
}
}
Error says:
Use of unassigned local variable 'keywords':
note that this code was under of a void condition in mainform:
private void TextChangedEvent(object sender, EventArgs e)
{
}
What should i do?