static classes, nested class, public class

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • puzzlecracker

    static classes, nested class, public class

    Would you quickly remind me the difference between, regular class,
    static class, and nested class?

    Thanks
  • Anthony Jones

    #2
    Re: static classes, nested class, public class

    "puzzlecrac ker" <ironsel2000@gm ail.comwrote in message
    news:5d893240-7046-4b86-a3f2-53a92ccd5183@n3 3g2000pri.googl egroups.com...
    Would you quickly remind me the difference between, regular class,
    static class, and nested class?
    >
    A 'regular' class my be used to create object instances for which the class
    is the type. Each instance will hold a set of fields which hold values for
    that instance only. A class may also contain static members which may be
    fields, properties or methods which are common across all instances of the
    class. Such static members are accessed through the Type name.

    A class marked as static may only contain static members and instances of a
    static class cannot be created.

    A nested class is a class that is defined inside another class. One
    difference that a nested class has from a regular class is that it may be
    private where it can only be used inside the class definining it, whereas a
    regular class cannot be private.

    --
    Anthony Jones - MVP ASP/ASP.NET

    Comment

    • Stanimir Stoyanov

      #3
      Re: static classes, nested class, public class

      A 'regular' class can contain any kind of members (fields, methods,
      properties, events et cetera), be it static or accessible through an
      instance only. A static class, however, can only contain static members and
      this is especially useful when the design you choose assumes that this class
      cannot or should not be instantiated, for example a set of helper functions.

      A nested class is defined within the scope of its 'parent' class--it may be
      private or accessible to external classes. You might want to choose to do
      this if your design assumes a hierarchical relationship between the two (or
      more) classes.
      --
      Stanimir Stoyanov
      메이저사이트 순위 먹튀검증이 완료된 토토사이트 커뮤니티 - 토토핫 입니다. 저희 토토핫에서는 베팅할때 필수로 점검해야 되는 안전 가이드를 제공하며 안전한 메이저 놀이터 목록과 메이저사이트 먹튀검증 꽁머니사이트를 추천드립니다.


      "puzzlecrac ker" <ironsel2000@gm ail.comwrote in message
      news:5d893240-7046-4b86-a3f2-53a92ccd5183@n3 3g2000pri.googl egroups.com...
      Would you quickly remind me the difference between, regular class,
      static class, and nested class?
      >
      Thanks

      Comment

      • Ben Voigt [C++ MVP]

        #4
        Re: static classes, nested class, public class

        Anthony Jones wrote:
        "puzzlecrac ker" <ironsel2000@gm ail.comwrote in message
        news:5d893240-7046-4b86-a3f2-53a92ccd5183@n3 3g2000pri.googl egroups.com...
        >Would you quickly remind me the difference between, regular class,
        >static class, and nested class?
        >>
        >
        A 'regular' class my be used to create object instances for which the
        class is the type. Each instance will hold a set of fields which
        hold values for that instance only. A class may also contain static
        members which may be fields, properties or methods which are common
        across all instances of the class. Such static members are accessed
        through the Type name.
        A class marked as static may only contain static members and
        instances of a static class cannot be created.
        >
        A nested class is a class that is defined inside another class. One
        difference that a nested class has from a regular class is that it
        may be private where it can only be used inside the class definining
        it, whereas a regular class cannot be private.
        Also, being a member of the containing class, it has permission to use
        private and protected members of the containing class. Static members are
        of course accessible directly, and instance members can be explicitly
        referenced using a reference to an object derived from the containing class.
        Note that these are NOT Java inner classes, there is no implicit reference
        to an instance of the containing class.

        And Java uses the static keyword very differently with member classes --
        Java defaults to defining an "inner class" and you use "static" to get a
        normal nested class. C# always gives you a nested class.


        Comment

        Working...