Fundamentals
-
What is the difference between internal and private access modifiers? If I declare a method as private and another method as internal, what's the difference? If I declare a class as private, what happens? Who will be able to use that class? Hope I find the answers soon, coz this thing is making my head spin round and round? :doh: :wtf: --- With best regards, A Manchester United Fan The Genius of a true fool is that he can mess up a foolproof plan!
-
What is the difference between internal and private access modifiers? If I declare a method as private and another method as internal, what's the difference? If I declare a class as private, what happens? Who will be able to use that class? Hope I find the answers soon, coz this thing is making my head spin round and round? :doh: :wtf: --- With best regards, A Manchester United Fan The Genius of a true fool is that he can mess up a foolproof plan!
-
What is the difference between internal and private access modifiers? If I declare a method as private and another method as internal, what's the difference? If I declare a class as private, what happens? Who will be able to use that class? Hope I find the answers soon, coz this thing is making my head spin round and round? :doh: :wtf: --- With best regards, A Manchester United Fan The Genius of a true fool is that he can mess up a foolproof plan!
Save My Soul - (SMS) wrote:
If I declare a class as private, what happens? Who will be able to use that class?
You can embed one class inside another. The class can be declared as private and only the containing class can use it.
public class ContainingClass
{
private class EmbeddedClass
{
// Stuff
}public void SomeMethod() { // This will work. EmbeddedClass o = new EmbeddedClass(); }
}
My: Blog | Photos "Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
-
Save My Soul - (SMS) wrote:
If I declare a class as private, what happens? Who will be able to use that class?
You can embed one class inside another. The class can be declared as private and only the containing class can use it.
public class ContainingClass
{
private class EmbeddedClass
{
// Stuff
}public void SomeMethod() { // This will work. EmbeddedClass o = new EmbeddedClass(); }
}
My: Blog | Photos "Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius