Comments on: C# Intermediate – Classes and Constructors https://code-maze.com/csharp-classes-constructors/ Learn. Code. Succeed. Sun, 19 Nov 2023 16:41:59 +0000 hourly 1 https://wordpress.org/?v=6.7.5 By: MarinkoSpasojevic https://code-maze.com/csharp-classes-constructors/#comment-6899 Wed, 09 Nov 2022 22:03:55 +0000 https://code-maze.com/?p=4449#comment-6899 In reply to James.

Hello James. Thanks for the kind words. Regarding your question, well we have to do that in many different cases. But we do that mainly because we want to do some sort of custom logic in that constructor and we don’t want a default constructor to set the values of all our members to default values. Also, on many occasions, we want to send some parameters to the constructors and then use them to do some business logic inside the class.

]]>
By: James https://code-maze.com/csharp-classes-constructors/#comment-6898 Wed, 09 Nov 2022 21:44:37 +0000 https://code-maze.com/?p=4449#comment-6898 Great website, a gem for learning c# & .net! Keep up the good work.

One question, if the compiler going to generate a default constructor, then why do we need to create any scenario?

]]>