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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:55:58+00:00 2026-06-03T02:55:58+00:00

i am aware of nested class. how could i design my nested class in

  • 0

i am aware of nested class. how could i design my nested class in such way that out side of parent class of nested class no one will be able to access nested class like instance create etc because i want the child class will be private. i want to expose my child class property, method everything by parent class property or method. please guide me to write the code for such kind of nested class. thanks

public class Person
{
private string _firstName;
private string _lastName;
private DateTime _birthday;

//...

public class FirstNameComparer : IComparer<Person>
{
    public int Compare(Person x, Person y)
    {
        return x._firstName.CompareTo(y._lastName);
    }
}

}
  • 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-06-03T02:55:59+00:00Added an answer on June 3, 2026 at 2:55 am

    Mark the internal class as private instead of public.

    public class Person
    {
        private string _firstName;
        private string _lastName;
        private DateTime _birthday;
    
        private FirstNameComparer firstNameComparer = new FirstNameComparer();
    
        public int CompareFirstNames(Person x, Person y)
        {
           return firstNameComparer.Compare(x, y);
        }
    
        //...
    
        private class FirstNameComparer : IComparer<Person>
        {
            public int Compare(Person x, Person y)
            {
                return x._firstName.CompareTo(y._lastName);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I aware that this will be a less programming question, but still... How can
I am aware that I can access all external links on a page using
Is anyone aware of any method (or external plugin) that would allow for nested
I was just made aware of a bug I introduced, the thing that surprised
I’m well aware of the Microsoft support base article stating that it’s not supported
JavaScript supports a goto like syntax for breaking out of nested loops. It's not
Anyone aware of an open source equivalent to full disk encryption products such as
Just wondering, if I want to create a class that does something and I
I've got a data file that is a single line consisting of a nested
I'm aware that NULL values in lists can sometimes trip people up. I'm curious

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.