Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# C# Collections Sets and Dictionaries Dictionary

What is the reasoning behind making the MorseCodeTranslator a static class?

Am I correct in presuming it is because the string values of TKey and TValue will never change?

2 Answers

Mark VonGyer
Mark VonGyer
21,239 Points

The class is static because the fields and functions are static, so allowing the class to be instantiated is pointless. The functions and fields are static because we expect the operation to remain the same in all situations.

K Cleveland
K Cleveland
21,839 Points

In a way, yes. You're not going to be changing anything with that class, inheriting it, or instantiating it. You're basically just going to access the members in the class and let them do whatever it is you'd like, as demonstrated by this line from the video:

string output = MorseCodeTranslator.ToMorse(input);

Good catch!