Non-overwritable function

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there!

I would like to create a non-overwritable function in C#.
Could someone suggest me?

Thanks.
 
Yes, I mean 'non-overridable'. Thanks for correction.
Could the sealed keyword be used for a user-defined function? I don't know
how to implement by using it. I want an equivalent to nonoverridable keyword
of vb. I would like to get a link or an example for that?

Thanks.
 
Could the sealed keyword be used for a user-defined function?

Yes. But if you define the method yourself it will be non-overridable
as long as you don't include the virtual keyword. sealed is only
needed if you want to prevent further overriding of an existing
virtual method.

I want an equivalent to nonoverridable keyword of vb.

Then you want sealed.



Mattias
 
Aung Thu said:
Yes, I mean 'non-overridable'. Thanks for correction.
Could the sealed keyword be used for a user-defined function? I don't know
how to implement by using it. I want an equivalent to nonoverridable keyword
of vb. I would like to get a link or an example for that?

By default, methods can't be overridden unless they're already
overriding the same method in the base class. If you need to override
something and make sure that no-one overrides it further, you just use
the sealed modifier.
 
Back
Top