'c# access modifier section like c++
Do I need to write all access modifiers in c#?
static class Node {
Node link;//Node * link;
int data;
public:
void setlink(Node next){...}
void display(){.....}
I want to use access modifiers section(public:, protected:)like in c++
how can I use it?
Do I have to write all of them?
public void setlink(Node next){...}
public void display(){...}
instead
public:
void setlink(Node next){....}
void display(){....}
Solution 1:[1]
Yes, you specify it on each member. Two good things about this:
- Moving the methods around within the same class can't affect anything.
- You can immediately see the access modifier by looking at the method declaration. No need to look higher up in the file to see if you're in a public section or not.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jon Skeet |
