By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,451 Members | 1,588 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,451 IT Pros & Developers. It's quick & easy.

constant methods, constant method parameters

P: n/a
Looks like c# does not have the ability to create constant methods or
constant parameters, is there an equilavent, or a reason why it was taken
out?
Jun 27 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Tue, 24 Jun 2008 15:23:49 -0700, Jeremy <no****@please.comwrote:
Looks like c# does not have the ability to create constant methods or
constant parameters, is there an equilavent, or a reason why it was taken
out?
You're right, it doesn't. As for why, I can't speak for the language
designers. But my experience has been that, while having "const" methods
and parameters _seems_ like a great idea, in practice it's often broken
anyway. It only works if you have complete control over every method
being called and can ensure that the methods always precisely describe
what they do via "const".

But in real life, for any interesting program, that's practically never
the case. So you wind up casting the "const" out, creating situations
that imply that the code is safe even though it's not (because you're
calling a method with "const" but somewhere deeper that "const" gets cast
away).

I believe that there have been at least a couple of threads in this
newsgroup in the past on the topic. So if you want to review those
threads, you may find more details.

Pete
Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.