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 6348371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:24:23+00:00 2026-05-24T21:24:23+00:00

Just on other thread at SO today i found this small snippet code which

  • 0

Just on other thread at SO today i found this small snippet code which i filled a bit more to make it complete,

class GameObject
{
    public virtual void Hello()
    {

        Console.WriteLine("Hello method in base class");
    }
}

class GameObjеct : GameObject 
{
    public override void Hello()
    {
        Console.WriteLine("Hello method in derived class");

    }

}

class Program
{

    public static void Main(string[] args)
    {
        GameObject obj = new GameObject();//Why i never can call Derived? Though c# allows it?
        obj.Hello();


        Console.ReadLine();
    }
}

Now as per the above code, the CSC shall not warning any thing at all. But the code works surprisingly.

I opened even the IL code using ILDasm, it shows the derived class i.e GameObject as ‘GameObject’ name and the base class name without ”.

So my question is

  1. how the compiler is differentiating these both class names plus even at run time?

  2. If pasted on notepad with ANSI encoding we get a weird char in the derviced class name as per my friend Abhishek sur. http://twitpic.com/68co6z

Thanks

EDIT: Update on the same code with different name, i am getting error from compiler.

class XXXYYY
    {
        public virtual void Hello()
        {

            Console.WriteLine("Hello method in base class");
        }
    }

 class XXXYYY : XXXYYY
    {
        public override void Hello()
        {
            Console.WriteLine("Hello method in derived class");

        }

    }

    class Program
    {

        public static void Main(string[] args)
        {
            XXXYYY obj = new XXXYYY();//Why i never can call Derived? Though c# allows it?
            obj.Hello();


            Console.ReadLine();
        }
    }
  • 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-24T21:24:24+00:00Added an answer on May 24, 2026 at 9:24 pm

    Basically the character that looks like “e” in the second classname is a non-ASCII character. If you put that source code into a text file with an encoding which supports it (e.g. UTF-8) and tell the C# compiler what encoding to use (UTF-8 by default, I believe) then it will view them as different class names.

    Ignoring the non-ASCII part, this is really just class:

    public class Hello {}
    
    public class He11o : Hello {}
    

    In some fonts you can tell the difference between lower-case-ell and one, but in some you can’t. They’re different characters though.

    When you tried to paste it into notepad it failed, because the ANSI encoding you’re using (ANSI is an ambiguous term) doesn’t include that character.

    EDIT: Your second snippet doesn’t compile for the obvious reason that you’ve got the same classname declared twice. Not two different names that look the same, but genuinely the same name.

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

Sidebar

Related Questions

I'm just wondering how other developers tackle this issue of getting 2 or 3
I just can't remember the terminology used for this and other related properties. EDIT
As you can see by reading my other thread today here , I'm having
I got this síngleton cache object and it exposes an IEnumerable property which just
Just wanted to check to make sure that I understand this. A synchronized method
I was expecting to find that section within System.Web.Configuration namespace just like other Web.config
Is there an ASP.NET AJAX framework other than just using UpdatePanel & Friends or
So I was playing around the other day just to see exactly how mass
I usually write C# programs for myself, or just parts of other applications. Now,
Just want to know if there other optional wrapper framework available that generate client

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.