Re: Rationale for CS0536?




> Still, this seems to be a cumbersome way to accomplish that behaviour.
> So, to come back to the basic question - why did they make it the way
> it is? Any case where there would be ambiguities when calling static
> members via instances?
>

It is this way because it distinguishes between an action on the type and on
the instance itself. Jon Skeet, another MVP who wanders these groups, likes
to use Thread.Sleep as an example

Thread t = ...;
t.Sleep(10);

What does that look like its doing to you? To me it looks like its putting
the thread referenced by t to sleep, however, its not. It is putting the
current thread to sleep since Sleep is a static method. If you did around
you will find alot of examples where that occurs.

Another example might be:

string s = "cat";

s = s.Concat("apple", "orange");
Console.WriteLine(s);

The expected result of that operation looks like it should be
"catappleorange", but it is actually "appleorange" since Concat is static
and does not act on the original variable. By not allowing statics to be
called through instances you don't have issues like that.


.



Relevant Pages

  • Re: Does sleep increase server load?
    ... JC> I'm pretty sure that this is a basic question, ... Does the sleep command increase the server load at all ... it just puts the calling process to sleep. ... I have a contact form that spam robots typically try ...
    (comp.lang.perl.misc)
  • Re: Bath vs shower
    ... >> To accomplish that without falling asleep from boredom I ... >> usually don't listen to and won't send me to sleep. ...
    (uk.local.cumbria)
  • Re: What features are missing from eBays system? You decide!
    ... >>> And it will accomplish what? ... I sleep with Meg and I can't get them to ... > She pays. ... Prev by Date: ...
    (alt.marketing.online.ebay)
  • Re: Does sleep increase server load?
    ... JC> I'm pretty sure that this is a basic question, ... Does the sleep command increase the server load at all ... it just puts the calling process to sleep. ... I have a contact form that spam robots typically try ...
    (comp.lang.perl.misc)
  • Re: Bath vs shower
    ... >> To accomplish that without falling asleep from boredom I ... >> usually don't listen to and won't send me to sleep. ...
    (uk.local.cumbria)