Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2008 > C# 2008 aka C# 3.0
|
C# 2008 aka C# 3.0 Discuss the Visual C# 2008 (aka C# 3.0) language
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2008 aka C# 3.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 8th, 2008, 04:06 PM
Friend of Wrox
 
Join Date: Sep 2007
Posts: 169
Thanks: 7
Thanked 2 Times in 2 Posts
Default Can I change how VS2008 generates certain items?

Hi

there is a couple things in VS2008 that are driving me crazy. One for instance is when you generate a class it does not put anything infront of it(private,public,internal or whatever).

 class CipherText
    {
    }

So that's is what it looks like I just read it apparently gets "internal" for it's view. The article I read said that this is fine for like 90% of the time. For me however I had to change one of my classes to public because I kept getting that "this class is less accessible then another classes error".


Took me forever to figure out that the class needed to be public. I don't really understand why they don't make it public in the first place. I noticed in my book too every time they did something they always had "public" specified what lead me to believe that vs2008 should have generated it when the class was made and mine was not.

Also if you have a file in like 2 different folders can't you just import the folder as a using package? Would that be the same as making one of them public?

Is there away to change it to display internal when the class is made? I don't like when stuff gets left out. I just find it easier to see stuff at face value and not have to recall that if left of in this place it defaults to internal but if you got a method and leave of the access modifier(or whatever you call private,public) it defaults to private.


So can I change that? Same with like when vs2008 generates your own customer event handler in code behind it drops of the private can you force it to display that too?

Thanks


 
Old October 8th, 2008, 04:16 PM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Classes, properties and fields all default to private (not internal).

You also seem to be confusing the concept of folders with namespaces. The "using" keyword allows you to reference classes in one namespace (similar in idea to the idea of packages from java, but not quite the same in implementation). Files in the same folder do not need to be in the same namespace, but certainly if they are ten you can add a single using statement that will add them all.

Code:
namespace Test
{
   public class Class1
   {
   }
}
and then

Code:
using Test;
Also, the feature you are trying to find is "Visual Studio Templates". These can be modified, but I really wouldn't recommend modifying the defaults. You could however add a new template called "Public C# Class" or something.

http://msdn.microsoft.com/en-us/library/6db0hwky.aspx


/- Sam Judson : Wrox Technical Editor -/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Change color of items in a ListView eresina Pro VB 6 6 September 15th, 2016 05:09 PM
SProc generates different results same data David_0223 SQL Server 2005 5 June 16th, 2008 05:52 PM
VS2008 Crashing? BigTallCampbell Visual Studio 2008 2 May 13th, 2008 10:05 PM
generates aspx pages dynamically and compile also shadab_17 ASP.NET 1.0 and 1.1 Professional 0 February 28th, 2007 02:35 AM
Listview doesnt change after items are selected. hexOffender VB.NET 2002/2003 Basics 0 December 13th, 2006 12:28 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.