I was just wondering, since the sealed keyword's existence indicates that it's the class author's decision as to whether other classes are allowed to inherit from it, why aren't classes sealed by default, with some keyword to mark them explicitly as extensible?
I know it's somewhat different, but access modifiers work this way. With the...
There were supposedly some classes in the LINQ to SQL provider model that were sealed--but I never really figured out exactly which classes need to be 'unsealed' in order to use it.
Hypothetically speaking, which classes do I need to unseal to enable the provider model?
[EDIT: I know that the sealed keyword means that it's not supposed...
A large number of classes in the .Net framework are marked as 'sealed', preventing you from inheriting those classes with your own. Surely this goes against the nature of object orientation, where you can extend and redefine the behaviour of existing objects.
Is there a good reason for the existence of the 'sealed' keyword?
As an ex...
I'm wondering how the following code is optimized. Specifically concerning virtual and direct calls. I have commented on how I think everything is optimized but those are just guesses.
public abstract class Super
{
public abstract void Foo();
public void FooUser()
{
Foo();
}
}
public class Child1 : Super
{
...
I was playing around with my MSVC++ compiler, and the properties tab for my point class said:
IsAbstract - false
IsInjected - false
IsManaged - false
IsSealed - false
IsTemplate - false
IsValue - false
What do these mean, and why were all of them greyed out except IsAbstract and IsSealed?
...
I've seen that you can manipulate private and internal members using reflection. I've also seen it said that a 'sealed' class is more secure that one that isn't.
Are the modifiers "public, protected, internal, private, abstract, sealed, readonly" anything more than a gentleman's agreement about design and API use, that can be broken as...
Running this code:
_foo = MockRepository.GenerateStub<IBar>();
_foo.Stub(x => x.Foo()).Return("sdf");
When
public interface IBar
{
string Foo();
}
public class Bar : IBar
{
public string Foo()
{
throw new NotImplementedException();
}
}
throws NotSupportedException - "Can't create mocks of sealed classes". I under...
This question really is kinda pointless, but I'm just curious:
This:
public sealed class MyClass
{
protected void MyMethod(){}
}
compiles, but gives a warning
while This:
public sealed class MyClass
{
public virtual void MyMethod(){}
}
doesn't compile. Just out of sheer curiosity, is there a reason for this?
...
If one can prevent subclassing by declaring private constructor in the base class, why do we need "sealed" keyword? Is it so because CLI can optimize it better? maybe.
Thanks.
...
I noticed that there are sealed and interface keywords in C++. Is this just for CLR C++?
If not, when were sealed and interface added to the C++ standard? Do they have the same meaning in C++ as they do in C#? If not, how do I get the equivalent in standard C++?
...
Why would anyone want to mark a class as final or sealed?
...
While inspecting the the .net object model in the Object Browser window, I came across the lack of information on sealed classes.
If for instance, one navigates to the mscorlib container -> System namespace -> String class, the details pane displays the following:
public class String
Member of System
Summary:
Represent...
Anyone have any opinions on whether or not IEquatable or IComparable should generally require that T is sealed (if it's a class)?
This question occurred to me since I'm writing a set of base classes intended to aid in the implementation of immutable classes. Part of the functionality which the base class is intended to provide is autom...
In Java final applies to more than just a class.
So, I wonder: is there any functional difference between the two keywords?
Thank you, and sorry for a relatively noob question.
A quick Google search did not satisfy my needs.
...
I have a class I am working with:
public sealed class WorkItemType
It's ToString is weak (Just shows Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemType).
Is there anyway to override this to show the name of the WorkItemType?
Normally I would just aggregate the value in a new class, but I am using this for bindings in WPF ...
Should I seal all classes I know shouldn't ever be used as a base class even when there are no tangible performance or security concerns, or is this just adding cruft?
...
I was about to inherit from the BitmapImage class when I noticed it was sealed, I've had a quick look around but I can't find a reason it is sealed.
Any body know why this is?
Thanks
...
I am using classes from a dll in my c++ project. All is working fine, until...
When trying to call a certain method (listed in the object browser), I am getting an error that this method is not a member of the namespace.
Upon invastigation, I noticed that this method is listed as "virtual void x() sealed".
Is there a way to make a cal...
I would like to make an object's structure immutable, preventing its properties from being subsequently replaced. The properties need to be readable, however. Is this possible?
I'm sure there are no language features (along the lines of final in Java and sealed in C#) to support this but wondered whether there might be another mechanism...
Assume the following: we have class B, which is a private class nested inside class A. There isn't any class inheriting from class B. The question is: will the compiler automatically mark class B as Sealed? (NonInheritable in VB). Is there any good reason for the compiler not to mark class B as sealed?
My line of thought is this: since...