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

  • SEARCH
  • Home
  • 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 7556135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:47:32+00:00 2026-05-30T11:47:32+00:00

I have a little console application that I’m tinkering with just to learn something

  • 0

I have a little console application that I’m tinkering with just to learn something new.

In the code below, in Console.WirteLine(), if I test t.IsAbstract, or t.IsSealed, my output is AbstractClass true, or SealedClass true respectively. All others return false as I expect.

However, if I test t.IsPublic, everything, including both PublicClass and PublicInterface return false. Why is that?

using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;

namespace ConsoleApplication1
{
    class Test
    { 
        static void Main(string[] args)
        {    
            Assembly assembly = Assembly.GetExecutingAssembly();
            Type[] assemblyTypes = assembly.GetTypes();
            foreach (Type t in assemblyTypes)
                Console.WriteLine(t.Name + " " + t.IsPublic);
            Console.ReadKey();
        }

        private class PrivateClass { }

        public class PublicClass { }

        protected class ProtectedClass { }

        sealed class SealedClass { }

        abstract class AbstractClass { }

        interface myInterface { }

        public interface PublicInterface { }
    }
}
  • 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-30T11:47:33+00:00Added an answer on May 30, 2026 at 11:47 am

    Because they are nested inside of Test.

    From the documentation: true if the Type is declared public and is not a nested type; otherwise, false.

    As @Jeb’s answer and the docs suggest, typeof(PublicClass) should have a value of true for the IsNestedPublic property

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

Sidebar

Related Questions

I have written a little console application that uses s#arp. I can create an
I have a little C# console application that reads a key and checks to
I have a little console application that has an embedded v8 engine, and I
I have a little console application that among other things checks the status of
I have a Windows CE console application that's entry point looks like this int
I have a little Node.js application that I'd like to hit a remote API
I have a little problem with a simple console application in which i would
We have an application that has one or more text console windows that all
I have a already compiled C++ console application wich is shown as a little
I have a little console C# program like Class Program { static void main(string

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.