You are correct in stating that you cannot directly inherit from value types like 'char' or 'int'. You can however create extension methods to add new functionality to these types by using a static class, for example, 'CharacterExtensions'. Inside this class, define static extension methods that take the 'char' type as the first parameter and the 'this' modifier. As an example -
public static class CharacterExtensions
{
public static bool IsVowel(this char c)
{
return "AEIOUaeiou".IndexOf(c) != -1;
}
public static bool IsConsonant(this char c)
{
return !c.IsVowel() && char.IsLetter(c);
}
}
In the above I have defined two extension methods - 'IsVowel' and 'IsConsonant'. These methods can be called on any 'char' instance as if they were instance methods of the char type. You can use this as in -
char letter = 'a';
bool isVowel = letter.IsVowel();
bool isConsonant = letter.IsConsonant();
letter = 'z';
isVowel = letter.IsVowel();
isConsonant = letter.IsConsonant();
You can now add similar to your static class to be used when needed.