#957 – Naming Files that Contain C# Code

Files that contain C# code are typically named using a .cs extension.  You can, however, include C# in a code having any extension you like.  Note that in Visual Studio, if the extension is other than .cs, you’ll need to set the Build Action to Compile.  The editor will also not use Intellisense on files having other extensions, unless you specifically change this.

A file containing C# code is most often named to represent a single class or type that it contains.  This helps in finding the source code that contains a particular class.

957-001

 

You can, however, store any type that you like within a particular file.

957-002

 

You might also store several types within the same file.

957-003

 

You can also split the implementation of a class across multiple files, using the partial keyword.

957-004

Advertisements

About Sean
Software developer in the Twin Cities area, passionate about .NET technologies. Equally passionate about my own personal projects related to family history and preservation of family stories and photos.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: