I asked in my studies build a "sealed " class and I don't really understand it's differents from regular class and what different in syntax it has

Thanks Sergey

Recommended Answers

All 13 Replies

a sealed class is a class that uses encapsulation. All its fields (properties) are private, as are all its methods.

It cannot be used or modified from any other class.

if you think of a normal class, you have say a form, you can add to it. You can make it your own, you can extend it..

A sealed class you cant, its as it is, it cannot be tampered with. To make it sealed, you simply add the word sealed as a moderator at the front.

Thanks to all,
Yes I tried now to build one that reached from
two others and in Main() I get that it doesn't know about any method in it so I can use it

that reached from
two others

What do you mean by that?
C# doesn't support multiple inheritance like C++.
And I really don't understand your problem with "sealed".
Sealed is as it says : "sealed". Even me, as a non native english speaker can understand the word.

No I know that C# work not like C++,
My class reach from one and his Parent byself child from another one,
II don't know why I can't see methods of my sealed class if methods are public ?

Perhaps you need to do some reading and research

yes i mde so and now it brought to me other
question and useful instruments
I discover that class can be abstract and
override
override I understood that one method use Parents same method but "abstract" is still a question for me

then you need to read more :)

"ithen you need to read more"

it's what I already done and after that I ask for help here
if I not mistaken it's purpose of this forum

Yes and no, unless you fancy getting your educational reward (eg school certificate, diploma etc) to us, you need to learn for yourself, we dont do your work for you, we will help you with it. Reading something as simple as what keywords mean and so on, is something you really really need to do for yourself.. You're the one in education after all, not me. I did my bit, and how did I learn? I taught myself, other than its pointless me copy and pasting an answer or explaining it in my own words when you could read it and find it yourself in information you already have.

There are a half a true in your words
but like you know there are no such books that have explanation about each keyword
(and I have not just one book) and explanation there forward mostly for experience people and I think good people always will be glad to help each other.
that a reason I ask for questions here

But there are.. type it in and press F1 it tells you and has examples for nearly everything - failing that type it in google! Theres so much information there right at your fingers, if you cant be bothered to try looking for yourself, it seems wrong for you to be expecting others to do it for you.

A sealed class is the one that you can't inherited from it since an error will occur if a sealed class is specified as the base class of another class. at the contrast of the normal class format

By the way you can declare a method as sealed within a normal class to prevent it from being overrided in the next derived class

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.