I always see people giving me code (I mean code examples for questions on SO and the like) like:
class MyData{
ObservableCollection<Color> Colors;
ObservableCollection<Fruit> Fruits;
ObservableCollection<Pairs> Pairs;
public void MatchCurrentSelection(){
.....
etc
}
}
}
Everytime I start writing code in visual studio, it forces me to declare the visibility, and always included in a namespace. Do people jsut leave out the namespace as its irrelevant? And why am I always forced to set the visibilty? (It appears to automatically append private by default)
namespace TheProject
{
public class MyData
{
private ObservableCollection<Colors> Colors;
private ObservableCollection<Fruits> Fruits;
...
etc
I have to be missing something here…What’s the story?
Thanks
If by “giving me code”, you mean providing samples/examples on stackoverflow, then visibility and namespacing has probably been ommited for brevity, I know I do!
It’s the same reason a large amount of sample code (here, and on places like msdn.microsoft.com) ommit most of the error-checking/handling, because having all that makes it harder to see the intent of the specific bit of code being provided as an example.