Multiple Classes per File | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Multiple Classes per File

In C#, is it common to have multiple classes in one file? Generally there would only be one class per file, right? Also, can the classes be called "public class" instead of just "class" (or "static class", that is)?

23rd Jan 2018, 4:27 AM
Physh
Physh - avatar
2 Answers
0
for organization most people keep to a one file per class style. the default access modifier is internal which hides its members and methods from other classes outside its namespace. You can have many access modifiers such as protected internal protected internal and private
23rd Jan 2018, 8:26 PM
John
John - avatar
0
in c# if no access specifier is procided it is implicitly internal, which restricts members of that type from being seen in other classes.
3rd May 2018, 11:54 PM
John
John - avatar