Re: class instance question

Paul van Brenk <[email protected]>
Newsgroups gmane.comp.windows.off-topic
Message-ID <[email protected]>
I think he means something like this in C#, which can't be reliably done due
to compiler not caring about  the name of things.

public class Cat
{
    public string Name
    {
         return .....;
    }
}

Somewhere else:

var Fluffy = new Cat();
Assert.IsTrue( Fluffy.Name == "Fluffy" );


The implementation of the return method is his question?

Paul

On Thu, Oct 21, 2010 at 15:36, Stoyan Damov <[email protected]> wrote:

>
>
> In C, this is already solved - there are no classes :P
> Seriously, I don't even want to know what John is talking about. I did try
> to understand his question though...
>
> On Fri, Oct 22, 2010 at 1:00 AM, Shawn Wildermuth <
> [email protected]> wrote:
>
>>
>>
>>  Um…in what environment?  Ruby? .NET? Java? C?
>>
>>
>>
>> Thanks,
>>
>> Shawn Wildermuth
>>
>> http://wildermuth.com
>>
>>
>>
>> Note: This was typed on a big ole laptop so any misspellings and
>> punctuations are completely my fault…not my phone’s.
>>
>>
>>
>> *From:* [email protected] [mailto:
>> [email protected]] *On Behalf Of *Ryan Heath
>> *Sent:* Thursday, October 21, 2010 5:46 PM
>> *To:* [email protected]
>> *Subject:* Re: [OT] class instance question
>>
>>
>>
>>
>>
>> Interesting, I do not know the answer, but instance names can be optimized
>> away.
>>
>> Lets say you have a solution for this problem, but then at runtime
>> 'Fluffy'
>> may be named as 'Register12' or 'Stack@17' or maybe, just boringly,
>> 'null' ;)
>>
>>
>>
>> // Ryan
>>
>> On Thu, Oct 21, 2010 at 11:36 PM, John Smith <[email protected]> wrote:
>>
>>
>>
>> Hi,
>> Is there a way to programmatically determine the name of an instance
>> of a class without having to hardcode the information?
>>
>> For example if I have a 'Cat' class and I have an instance of that
>> class named 'Fluffy' assuming the Cat class has a 'Name' member
>> variable that can hold the information, is there a way to make
>> 'Fluffy' determine its own name without having to tell it the
>> information? Just curious... Thanks.
>>
>>
>>
>>
>
>
> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.