Recently my colleague asked me this question, "Can a private class can be inherited by another class?" What do you think Yes? or No?
Question itself is invalid. There are no private classes in c#(Except nested classes). A class can be either public or internal only. You can't have other access modifiers.
Ok, lets convert the question now to "Can an internal class can be inherited by a public class"?
Answer : No
Class "B" can inherit from class "A", only if "A" has more or equal accessibility than "B". If class "A" is internal and class "B" is public, it means "A" has less accessbility than "B". So, "B" can't inherit from "A"
Published under: Microsoft .NET Tips · · · ·
You can prepare a series on these kind of question. This will be very much interesting.
I will second that - a series on these basic fundamentals would be very interesting to read.
Thanks Manas & Nakul for your kind comments... :) I am working on this... Until that i will share daily tips here
One of my friend was asked in an interview like 3 classes are there in 3 assembles A,B,C .Out of this B can inherit A but C can't inherit A.Can we achieve this?if YES how?