I am often times wondering how I can write cleaner better code that is effective, but not reeeeealy long. As a beginner this is something you wish you can do, but blow it off until you get better at programming feeling eventually you’ll “get it”.
Often times with beginners there might be code that looks like this.
public void Display(string s1, string s2)
{
string sentence1 = s1;
string sentence2 = s2;
Console.WriteLine(sentence1 + ". " + sentence2);
}
While this may look odd there are plenty of examples of SIMILAR code in beginners. And as you have probably figured out an easy way to shorten the code would be to do this.
public void Display(string s1, string s2)
{
Console.WriteLine(s1 + ". " + s2);
}
The code looks cleaner and slimmer and a little easier to understand. So I recommend to write cleaner looking code try to get rid of as many variables as you can, but be careful not to take away to many.
Again I just want to re-iterate my purpose for these types of posts is to help beginners in places I wanted/needed help on with I first started, and still need help on to some degree.