|
I want to allow the class to create only one object instance.
I want to make visible the class ouside the assembly but restrict to only one assembly.
What needs to do?
Please suggest me.
|
|
|
|
|
|
What does this have to do with OOPS concepts? What you are describing is such a basic request that it's part of the framework; we call them "static classes".
public static class MySingleObjectClass
{
public static void PerformSomeAction()
{
}
}
|
|
|
|
|
If we create static class , we cannot able to create instance. but ,my query is that instance should be created only one time and restrict to more than one.
|
|
|
|
|
9500394002 wrote: If we create static class , we cannot able to create instance.
There's one instance by definition, so no use in creating it.
9500394002 wrote: but ,my query is that instance should be created only one time and restrict to more than one.
That's exactly what the static class was intended for.
|
|
|
|
|
If you want to restrict the class so that it can only be seen by one particular external assembly, you use internal to limit the scope to the current assembly, and then you implement InternalsVisibleTo[^] to link this to the specific assembly.
|
|
|
|
|
Are you suggesting InternalVisible to be used in the parent class?
Up to my knowledge InternalVisible access modifier is not there in c#
|
|
|
|
|
Did you even bother opening the link in the answer?
|
|
|
|
|
No, because that would violate the rules of "spoon feeding".
|
|
|
|
|
Don't you just love my hopeless optimism?
|
|
|
|
|
Sorry i could n't noticed that.I will read your suggestion and get back to you if any queries
|
|
|
|