I am replacing some very small bash scripts with Mono (C#). I have noticed some differing practices in C# tutorials online regarding convention. I'd like to know the reasoning behind them. If I should break this question up into multiple questions, let me know.
1) Use a namespace? I see that many tutorials don't bother with this, but some do. If the app is all contained in the Main and maybe a few other small functions, should I even bother with the namespace?
namespace SmallApp {
class DoSomething {
public static void Main(string[] args) {
// code here;
}
}
}
class DoSomething {
public static void Main(string[] args) {
// code here;
}
}
2) Public class? Some tutorials have the public modifier on the class, and some don't. I know that in Java the class must be marked as public, but in C# it seems to not matter. Your thoughts?
namespace SmallApp {
public class DoSomething {
public static void Main(string[] args) {
// code here;
}
}
}
namespace SmallApp {
class DoSomething {
public static void Main(string[] args) {
// code here;
}
}
}
3) Static Main? Some tutorials have the static modifier on the Main method, and some don't. I know that in Java the main method must be marked as static, but in C# it seems to not matter. Your thoughts?
namespace SmallApp {
public class DoSomething {
public static void Main(string[] args) {
// code here;
}
}
}
namespace SmallApp {
public class DoSomething {
public void Main(string[] args) {
// code here;
}
}
}
Thank you for your thoughts!