Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6544191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:26:10+00:00 2026-05-25T11:26:10+00:00

Is this possible!!?!?!?!? I’m trying to make a set of classes that model a

  • 0

Is this possible!!?!?!?!?

I’m trying to make a set of classes that model a number of different types of things. Properties of these things change over time, and I want my code to be easy to maintain, so I want to do something like the following:

public class Cat
{
    public string CatName { get; set; }

    public Cat()
    {
        this.CatName = MAGICSTUFF.GetInstanceName(this);
     }

}

Somewhere else, when I want to get at those cats, I want to be able to say:

[TestMethod]
public void test_awesome_cats()
{
    Cat Tiger = new Cat();
    Assert.IsTrue(Tiger.CatName.Equals("Tiger"));
}

So, I’m trying to map my naming convention into object properties. The part I can’t figure out is the MAGICSTUFF.GetInstanceName. Is that a thing?

I suspect this is impossible, so if that’s the case hopefully somebody can give me some other ideas on clever ways to use convention for this type of scenario. I’ve been thinking of using attributes for the Cat class for a while, but I like this was a lot better if its possible.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:26:11+00:00Added an answer on May 25, 2026 at 11:26 am

    It’s not possible to do that kind of reflection. Variable names could be erased by the compiler depending on debugging options and scope. The name of a variable is an alias of its “address” so can not be reversed (at least in Java and C# AFAIK).

    An object can be pointed from nay variables, so the variable name is irrelevant and the object don’t know this kind of stuff:

    Cat tiger = new Cat();
    Cat tiger2 = tiger;
    

    Variable tiger2 points to the Cat “tiger”, so 2 variable points same object with different names.

    Use class properties passed in the constructor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to handle this possible exploit and wondering what is the best way
Is this possible? I am trying to open a SQLite database cursor in one
Is this possible? If it is, how? And if not, which compiler that does
Is this possible in phpMyAdmin, to execute that query on all records within a
Is this possible? I want to have the To:, Body, and an Attachment all
Is this possible? I am looking forward to a tutorial which explains the steps
Is this possible? I had troubles with SVN clients not being able to access
Is this possible? I can't find it anywhere.
Well I tried to figure out is this possible in any way. Here is
Helo! Is this possible to use string value of one node which tells what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.