Hey guys I cant manage with this code. The idea is to return default English alphabet in case of erroneous create method execution. Thanks.
An idea to override explicit operator is good, but i cant imagine an implementation of casting.
namespace trie
{
class AlphabetFactory<T> where T: IConvertible
{
public Alphabet<char> SetDefaultAlphabet()
{
var list = new char[26];
for (var i = Convert.ToInt32('a'); i <= Convert.ToInt32('z'); i++)
list[i] = Convert.ToChar(i);
return new Alphabet<char>(list);
}
public Alphabet<T> Create(params T[] list)
{
if (list != null)
return new Alphabet<T>(list);
else
return SetDefaultAlphabet(); // <- This is not correct
}
}
}