Results 1 to 10 of 10

Thread: [RESOLVED] [1.0/1.1] Default Class Scope

  1. #1

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    Resolved [RESOLVED] [1.0/1.1] Default Class Scope

    Does anyone know if there is a way to change the default class scope and constructor scope when creating a new class? 90% of my classes are internal, so I have to change the scope from public to internal and the default constructor every time. Just a small annoyance but an annoyance non the less.

  2. #2

  3. #3

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    Re: [1.0/1.1] Default Class Scope

    Bloody annoying little thing, bugs me every time. How many people need public classes all the time? Internal has to be the most common scope.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [1.0/1.1] Default Class Scope

    I'm sure that you could create a VS macro to do it, although I have next to no experience with IDE macros so I couldn't give you any details.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    Re: [1.0/1.1] Default Class Scope

    Am I the only person who thinks that internal should be the default scope for new classes and their default constructor?

  6. #6
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476

    Re: [1.0/1.1] Default Class Scope

    Here is what you can do:

    Browse in your explorer to:
    C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\VC#Wizards\CSharpAddClassWiz\Templates\1033

    Open the File "NewCSharpFile.cs" A Text Editor would do just fine.

    Modify to your needs.

    Save.
    Close and reopen VS.

    Now everytime you add a new Class, your new File will be the template for it.
    You might want to save the original File somewhere, just in case you screw up !

    Stephan
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

  7. #7

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    Re: [1.0/1.1] Default Class Scope

    Thanks a lot, that's it sorted.

  8. #8
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: [RESOLVED] [1.0/1.1] Default Class Scope

    Nice one Sgt Onion

    That's very very cool to know...more annoying that the class scope is adding/removing default comments too. imo.

    Woooooof

  9. #9
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [1.0/1.1] Default Class Scope

    Quote Originally Posted by GlenW
    Am I the only person who thinks that internal should be the default scope for new classes and their default constructor?
    I agree that the default scope for classes should be internal, but once the class is internal it doesn't matter if its members are public. You can't access a public member of a class you can't see, so a public constructor of an internal class is inaccessible from outside the current assembly.

    Nice info Sgt-Peppa. I think I'll have a look for the VB equivalent too.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  10. #10

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    Re: [1.0/1.1] Default Class Scope

    Quote Originally Posted by jmcilhinney
    I agree that the default scope for classes should be internal, but once the class is internal it doesn't matter if its members are public. You can't access a public member of a class you can't see, so a public constructor of an internal class is inaccessible from outside the current assembly.
    Yes, I know, I did say it was a small annoyance, but I'm just a pedant.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width