Forum C# Class files structure

Class files structure

Postby sidwoo » November 26th, 2010, 4:54 pm

Hi,

i was wondering how to organise my file and classes structure in C#.

In AS3 the folder structure must fit the namespaces, but in C# it seems to be different?

The file is called Game.cs but the namespace is MyGame?
Also in the examples several Classes are put into one file which i really don´t like very much.

I tried to create more files but i couldnt even do that in VS2010?
Found no option similar to "create C# file".
created a file outside of VS but VS doesn´t recognize it as a C# file?

And a final question ... is there an Outline view as in Flashdevelop?

Sorry for all these newbish questions ;)
sidwoo
 
Posts: 13
Joined: November 23rd, 2010, 5:45 pm

Re: Class files structure

Postby TobiasW » November 26th, 2010, 7:29 pm

Hey there!

sidwoo wrote:In AS3 the folder structure must fit the namespaces, but in C# it seems to be different?

The file is called Game.cs but the namespace is MyGame?

In C# there is usually a "Default Namespace" (which you can change in the project properties right on the first page). Assuming "MyGame" is your default namespace, then a folder "Data" would usually contain classes with the namespace "MyGame.Data" - so it's like AS3 except that the highest level has a namespace too. (Oh, and that it is "usually" this way. It is no "must" in C#, you can do what you want.)

Also in the examples several Classes are put into one file which i really don´t like very much.

Me neither. Just don't do it yourself.

I tried to create more files but i couldnt even do that in VS2010?
Found no option similar to "create C# file".

[Rightclick on the project or a folder inside the project] -> [Add] -> [New Item]

And a final question ... is there an Outline view as in Flashdevelop?

Not that I know of. Though... didn't search for it. Maybe there is a plugin.

Sorry for all these newbish questions ;)

You're welcome!

Hope that helped,
Tobias
User avatar
TobiasW
 
Posts: 59
Joined: August 29th, 2010, 12:31 am

Re: Class files structure

Postby sidwoo » November 27th, 2010, 4:39 pm

that helped, thanks!
sidwoo
 
Posts: 13
Joined: November 23rd, 2010, 5:45 pm


Return to C#



cron