When to use NotInheritable and shadows?

When to use NotInheritable and shadows?

am 14.01.2008 17:16:08 von Siegfried Heintze

Both C# and VB.NET have some strange keywords.

When would someone want to use NotInheritable (or sealed in C#)?

When would someone want to use shadows?

Thanks,
Siegfried

Re: When to use NotInheritable and shadows?

am 14.01.2008 18:52:47 von skeet

Siegfried Heintze wrote:
> Both C# and VB.NET have some strange keywords.
>
> When would someone want to use NotInheritable (or sealed in C#)?

As often as possible. If you're not explicitly designing for
inheritance (which incurs a significant cost, if done properly) then
sealing the class is a good idea. I often forget to do it, and wish it
were the default, but controlling inheritance is a good plan.

> When would someone want to use shadows?

As rarely as possible - only when you absolutely have to, IMO. It makes
the code hard to understand.

--
Jon Skeet -
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk

Re: When to use NotInheritable and shadows?

am 14.01.2008 20:58:06 von NoSpamMgbworld

"Siegfried Heintze" wrote in message
news:Ol68FjsVIHA.4880@TK2MSFTNGP03.phx.gbl...
> Both C# and VB.NET have some strange keywords.
>
> When would someone want to use NotInheritable (or sealed in C#)?

When you do not want a class to be inheritable.

public class ThisShouldNotBeInherited
{
}

public class IAmInheritingThatClass : ThisShouldNotBeInherited
{
}

The above is perfectly legal, as it stands.

When? There are lots of instances.

1. Library specifically targeted to a single peripheral device
2. Library that maps to a table in your database

> When would someone want to use shadows?

When you absolutely have to make a method of the same name without
overriding it. Overall, I agree with Jon that this is not a wise practice to
get in the habit of doing.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box!
|
*************************************************

Re: When to use NotInheritable and shadows?

am 16.01.2008 00:15:41 von skeet

Jer. 7. Reprobation of the Temple: "Go ye unto Shiloth, where I set my name
at the first, and see what I did to it for the wickedness of my people. And
now, because ye have done all these works, saith the Lord, I will do unto
this house, wherein my name is called upon, wherein ye trust, and unto the
place which I gave to your priests, as I have done to Shiloth." (For I have
rejected it, and made myself a temple elsewhere.)

"And I will cast you out of my sight, as I have cast out all your brethren,
even the seed of Ephraim." (Rejected for ever.) "Therefore pray not for this
people."

Jer. 7:22: "What avails it you to add sacrifice to sacrifice? For I spake
not unto your fathers, when I brought them out of the land of Egypt,
concerning burnt offerings or sacrifices. But this thing commanded I them,
saying, Obey and be faithful to my commandments, and I will be your God, and
ye shall be my people." (It was only after they had sacrificed to the golden
calf that I gave myself sacrifices to turn into good an evil custom.)

Jer. 7:4: "Trust ye not in lying words, saying, The temple of the Lord, the
temple of the Lord, the temple of the Lord, are these."

714. The Jews witnesses for God. Is. 43:9; 44:8. Prophecies fulfilled.--I
Kings 13:2. I Kings 22:16. Joshua 6:26. I Kings 16:34. Deut. 23.

Malachi 1:11. The sacrifice of the Jews rejected, and the sacrifice of the
heathen, (even out of Jerusalem,) and in all places.

Moses, before dying, foretold the calling of the Gentiles, Deut. 32:21. and
the reprobation of the Jews.

Moses foretold what would happen to each tribe.

Prophecy.--"Your name shall be a curse unto mine elect, and I will give them
another name."

"Make their heart fat," and how? by flattering their lust and making them
hope to satisfy it.

Re: When to use NotInheritable and shadows?

am 16.01.2008 01:49:39 von Siegfried Heintze

nothing: both their love and their
hatred is to be despised. The wrath of the great King of kings, is as
much more terrible than theirs, as his majesty is greater. Luke 12:4,5.
"And I say unto you, my friends, Be not afraid of them that kill the
body, and after that, have no more that they can do. But I will forewarn
you whom you shall fear: fear him, which after he hath killed, hath
power to cast into hell: yea, I say unto you, Fear him."

It is the fierceness of his wrath that you are exposed to. We often read
of the fury of God; as in Isa. 59:18. "According to their deeds,
accordingly he will repay fury to his adversaries." So Isa. 66:15. "For
behold, the Lord will come with fire, and with his chariots like a
whirlwind, to render his anger with fury, and his rebuke with flames of
fire." And in many other places. So, Rev. 19:15, we read of "the wine
press of the fierceness and wrath of Almighty God." The words are
exceeding terrible. If it had only been said, "the wrath of God," the
words would have implied that which is infinitely dreadful: but it is
"the fierceness and wrath of God." The fury of God! the fierceness of
Jehovah! Oh, how dreadful that must be! Who can utter or conce

Re: When to use NotInheritable and shadows?

am 16.01.2008 02:07:44 von NoSpamMgbworld

if you desire with all your heart to know it, it is not
enough; look at it in detail. This would be sufficient for a question in
philosophy; but not here, where it concerns your all. And yet, after a
trifling reflection of this kind, we go to amuse ourselves, etc. Let us
inquire of this same religion whether it does not give a reason for this
obscurity; perhaps it will teach it to us.

227. Order by dialogues.--What ought I to do? I see only darkness
everywhere. Shall I believe I am nothing? Shall I believe I am God?

"All things change and succeed each other." You are mistaken; there is...

228. Objection of atheists: "But we have no light."

229. This is what I see and what troubles me. I look on all sides, and I see
only darkness everywhere. Nature presents to me nothing which is not matter
of doubt and concern. If I saw nothing there which revealed a Divinity, I
would come to a negative conclusion; if I saw everywhere the signs of a
Creator, I would remain peacefully in faith. But, seeing too much to deny
and too little to be sure, I am in a state to be pitied; wherefore I have a
hundred