|
Pete O'Hanlon wrote: ClassNameBase myclass = new ClassNameBase();ClassName concreteImpl = myClass;
I'm not sure how useful this would be, but it could be done.
Actually it cant be done :p You would need an implicit cast from a base class to it's parent derivation, and the CLR does not permit that.
See my post for the likely explanation why it is sealed with an internal constructor.
|
|
|
|
|
You're right of course. How could I have missed that? A 5 for spotting my stupidity.
|
|
|
|
|
VentsyV wrote: The constructor is internal and the class is in a DLL, therefore you can't create an instance of the class either.
That is correct, but it's likely the library writer wants to expose the instance via a member, but still disallow instantiation. IMO, this shows a very good knowledge of the language/platform being dealt with (unless it really was a mistake!).
|
|
|
|
|
If the class is laid out without any other members (as in the OP) then this wouldn't be it.
|
|
|
|
|
Pete O'Hanlon wrote: If the class is laid out without any other members (as in the OP) then this wouldn't be it.
You missed the '//Stuff' bit?
|
|
|
|
|
Damn - I did . If I'd seen that, I'd have answered the same as you - I guess I have "stuff" blindness (I'd normally put this in as // Do Something here).
|
|
|
|
|
leppie wrote: That is correct, but it's likely the library writer wants to expose the instance via a member, but still disallow instantiation
Can you explain this ?? I can't make sense out of it. What instance ?? There is no way you can create any instance of this class, as it is in assembly by itself.
|
|
|
|
|
VentsyV wrote: There is no way you can create any instance of this class, as it is in assembly by itself.
First off, if this class in an assembly by itself and the assembly does not have any friend assemblies, the rest that follow is irrelevant. Then it means he uses reflection for something stupid.
You need to understand that you dont need to create an instance.
Lets take a 'real world' example (this is in xacc.ide, not sure how real world it is ):
public sealed class TextBuffer
{
internal TextBuffer(AdvancedTextBox atb) { ... }
}
public class AdvancedTextBox
{
public TextBuffer Buffer {get {return buffer;}}
public AdvancedTextBox()
{
buffer = new TextBuffer(this);
}
}
Now I dont want anyone to use the TextBuffer class without using my AdvancedTextBox class. In other words, the author states the class is not usable without accessing it thought an AdvancedTextBox instance, for whatever reason that may be (perhaps unstable, restricted, propriety, etc).
Note: the example is not exactly like it is in xacc.ide, I rather use the better approach of making TextBuffer a nested class of AdvancedTextBox, thus giving me even more flexibility on usage.
|
|
|
|
|
Might there be a factory method?
|
|
|
|
|
No, he states that there are no static members.
|
|
|
|
|
Oh, yeah, I knew that...
|
|
|
|
|
Thats exactly what I've been saying all along. The class is in assembly by itself and there are no friend assemblies declared. There are no static members either.
I'm not an expert in C# but to me that makes no sense whatsoever.
Also, in the example you gave, you did create an instance of TextBuffer, and by the way, you have to declare buffer (lowercase 'b') somewhere or you'll get a compiler error.
|
|
|
|
|
I once asked another 'senior' programmer to check his work again for bugs, and his reply was: "Alright, I'll check my codes."
Me: It's "code", not "codes".
Every time someone calls it "codes" instead of "code", it feels like I'm getting stabbed in the ear with a ice pick. Does anyone else here get the same feeling when people can't seem to say things correctly when it comes to programming?
|
|
|
|
|
Philip Laureano wrote: Every time someone calls it "codes" instead of "code", it feels like I'm getting stabbed in the ear with a ice pick. Does anyone else here get the same feeling when people can't seem to say things correctly when it comes to programming?
Personally, I think it feels like I'm using a cheese grater on my ears.
|
|
|
|
|
Philip Laureano wrote: Every time someone calls it "codes" instead of "code", it feels like I'm getting stabbed in the ear with a ice pick.
How about "softwares"?
|
|
|
|
|
Nemanja Trifunovic wrote: How about "softwares"?
That one too. My favorite one has to be when someone pronounces C# as "C Pound"...
|
|
|
|
|
Philip Laureano wrote: My favorite one has to be when someone pronounces C# as "C Pound"...
I've heard recruitment companies call it C-Hash.
How come the # is "pound"? The pound symbol is this: £
|
|
|
|
|
In the US # is sometimes used to indicate a weight pound. Lbs is more common, especially now that labels/signs are almost entirely printed instead of hand written.
Otherwise [Microsoft is] toast in the long term no matter how much money they've got. They would be already if the Linux community didn't have it's head so firmly up it's own command line buffer that it looks like taking 15 years to find the desktop.
-- Matthew Faithfull
|
|
|
|
|
Also, we call the # symbol on the phone "pound".
|
|
|
|
|
In my country - we call it the hash.
|
|
|
|
|
You know, I never called that thing the 'pound' until maybe around 1994... I always called it the number sign before. The British L-shaped thing is the pound sign. The # is the 'number' sign... as in "We're #1!"
|
|
|
|
|
After having worked with a bunch of old bell system telecom engineers I learned that the symbol is actually an octothorpe. Certainly not a very sharp sounding name. Brings to mind tentacles of spaghetti code.
|
|
|
|
|
Here is another one... When some error occurs there's always someone suggesting "Lets check the Lots ...." jajjaa it is LOG, not Lots...jijiji occurs when the person is a spanish speaker...
Mark Paint.
Education is the ability to listen to everything without losing your temper and self-confidence.
|
|
|
|
|
Mario_F wrote: "Lets check the Lots ...." jajjaa it is LOG, not Lots...jijiji
And it is "ha ha ha" and "he he he" - this also occurs with Spanish speakers.
|
|
|
|
|
yep, you're right... but this one is a readable, doesnt affect your ears
Mark Paint.
Education is the ability to listen to everything without losing your temper and self-confidence.
|
|
|
|