473,387 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How many classes are allowable in one file?

Hi,

Happy NY, folks. I've just a two simple questions:

Can there be more than 1 class per file?

Can I declare more than 1 public class per file?

I tend to think yes on both. Is there execptions?

Thanks.

light_wt.
Nov 15 '05 #1
4 3095
light_wt,

Yes, you can have more than one class per file. I don't believe there
is a limit (although it may become impractical at some point if you have too
much).

One caveat. The win forms designer likes to have one class (the form it
is designing) per file. It has something to do with the resx files it
generates.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"light_wt" <li*****************@hotmail.com> wrote in message
news:00****************************@phx.gbl...
Hi,

Happy NY, folks. I've just a two simple questions:

Can there be more than 1 class per file?

Can I declare more than 1 public class per file?

I tend to think yes on both. Is there execptions?

Thanks.

light_wt.

Nov 15 '05 #2
It is only a convention that people put one class per file but you can have
as many as you want. You could have your entire application contained
within a single file if you want.

"light_wt" <li*****************@hotmail.com> wrote in message
news:00****************************@phx.gbl...
Hi,

Happy NY, folks. I've just a two simple questions:

Can there be more than 1 class per file?

Can I declare more than 1 public class per file?

I tend to think yes on both. Is there execptions?

Thanks.

light_wt.

Nov 15 '05 #3
"light_wt" <li*****************@hotmail.com> wrote:
Can there be more than 1 class per file?
Can I declare more than 1 public class per file?
I tend to think yes on both. Is there execptions?


You can have more than one class in a file.

I think the Windows Forms Designer will only let you view and edit a form if
it is the first class in the file.

P.
Nov 15 '05 #4
Pether, Paul, and Nicholas,

Thanks for your reply and clarifying.
Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Phil Powell | last post by:
Where can I find an online PHP form validator script library to use? I have tried hacking the one here at work for weeks now and it's getting more and more impossible to customize, especially now...
1
by: Miranda Evans | last post by:
Seeking reference material (a url, a book, an article) that offers advice and guidelines for organizing classes within files. For example, assume two classes: 1) SuperABC - a superclass 2)...
1
by: b | last post by:
I have a web application enforcing IE to use 128 bit encyption. I've been told that it is to be accessed from Europe now. Does anyone know where I can find information on countries and allowable...
9
by: Aguilar, James | last post by:
I know that one can define an essentially unlimited number of classes in a file. And one can declare just as many in a header file. However, the question I have is, should I? Suppose that, to...
12
by: Langy | last post by:
Hello I'm fairly new to C++ but have programmed several other languages and found most of c++ fairly easy (so far!). I've come to a tutorial on classes, could someone please tell me why you...
9
by: Gomaw Beoyr | last post by:
Two question about the "partial classes" (in the next wersion of ..NET). Question 1 ========== Will partial classes (in the next version of C#) have to be declared "partial" in ALL places. ...
10
by: ptass | last post by:
Hi In asp.net 2.0 an aspx files .cs file is a partial class and all works fine, however, I thought I’d be able to create another class file, call it a partial class and have that compile and...
0
by: JohnyStyles | last post by:
I have a templated user control which looks like this: ----------------------------------------------------------------- <uc:MyUserControl runat=server> <TemplateProperty> </TemplateProperty>...
14
by: mssprogram | last post by:
I'm using Bloodshed's Dev-C++. I can't get this code to work. Can someone tell me what's wrong? int a, b, c, ave; cout << "Enter three test scores: " << endl; cin >> a >> b >> c; ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.