creating a program the a user can enter words and it pops out an acronym and that's easy but i have to use a dictionary and the keys have to make the acronym i'm given NullReferenceException don't understand why can't see a null
just using visual studio 2015 I've tried so much my minds blown can't even describe the problem all that well sorry
private string fullSentence;
private string[] words = new string[5];
private Dictionary<char, string> acronymDictionary = new Dictionary<char, string>();
public Acronym(string sentence)
{
fullSentence = sentence;
string[] words = sentence.Split(' ');
}
public void BuildAcronym()
{
char[] key = new char[words.Length];
//key = null;
//foreach (string info in words)
//{
for (int i = 0; i < words.Length; i++)
{
key[i] = Convert.ToChar(words[i].Substring(0,1)); //this is where the problem is
}
I expect it to run, specifically for the key chars[] to be populated by the first letter of each word in words[] so i can set key[] as the keys for the dictionary