473,386 Members | 1,864 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,386 software developers and data experts.

Multiple files project in C#

Hi,

I have a decent amount of programming experience in C/C++ and have
recently heard very good things about C#. So I decided to take a
look...

The lexical elements and language layout make it a little closer to
Java than to either C or C++, which is pretty interesting.

A question about a project that has say two .cs files. The first class
has the Main() method and the second class has got a non-static public
method called NormsDist().

If I instantiate both classes, how do I call NormsDist() from Main()?
In C++ I would have to include the method in a header file imported by
Main(), so how would the equivalent step work in C#?

Thanks in advance,
Schiz

Aug 26 '06 #1
5 5022
schizoid_man wrote:
I have a decent amount of programming experience in C/C++ and have
recently heard very good things about C#. So I decided to take a
look...

The lexical elements and language layout make it a little closer to
Java than to either C or C++, which is pretty interesting.

A question about a project that has say two .cs files. The first class
has the Main() method and the second class has got a non-static public
method called NormsDist().

If I instantiate both classes, how do I call NormsDist() from Main()?
In C++ I would have to include the method in a header file imported by
Main(), so how would the equivalent step work in C#?
You need to do have an instance of the class to call the
method just like in C++.

But you do not need to do anything to have the functionality
available (like C++ include).

If it is in a different namespace then you can optionally
have a using statement.

Arne
Aug 26 '06 #2

Arne Vajhøj wrote:
You need to do have an instance of the class to call the
method just like in C++.

But you do not need to do anything to have the functionality
available (like C++ include).

If it is in a different namespace then you can optionally
have a using statement.
Hi Arne,

The problem is - what if I have a really large project? It is
concievable that different classes could have the same method name(s)
and the same input parameters.

How would I control which methods are the ones used? Since there is no
method 'filtering' in the include file, would this be done simply by
using whichever objects have instantiated the respective
classes/methods?

Thanks.

Aug 27 '06 #3
schizoid_man wrote:
Arne Vajhøj wrote:
>You need to do have an instance of the class to call the
method just like in C++.

But you do not need to do anything to have the functionality
available (like C++ include).

If it is in a different namespace then you can optionally
have a using statement.
The problem is - what if I have a really large project? It is
concievable that different classes could have the same method name(s)
and the same input parameters.

How would I control which methods are the ones used? Since there is no
method 'filtering' in the include file, would this be done simply by
using whichever objects have instantiated the respective
classes/methods?
Classes with different names but same method signatures = no problem.

Classes with same name and same method signatures = problem, which
can and should be solved by using namespaces.

BTW, I do not think that is really so different from C++. Sure
you will not get a compile error if only you include one declaration
in the header files. But you will eventually get a link error.

Arne
Aug 27 '06 #4
Arne Vajhøj wrote:
schizoid_man wrote:
The problem is - what if I have a really large project? It is
concievable that different classes could have the same method name(s)
and the same input parameters.

How would I control which methods are the ones used? Since there is no
method 'filtering' in the include file, would this be done simply by
using whichever objects have instantiated the respective
classes/methods?

Classes with different names but same method signatures = no problem.

Classes with same name and same method signatures = problem, which
can and should be solved by using namespaces.
Yes, I suppose only the first situation should arise. Same names and
method signatures for different classes is probably poor design in any
case.
BTW, I do not think that is really so different from C++. Sure
you will not get a compile error if only you include one declaration
in the header files. But you will eventually get a link error.
Thanks for the help.

Aug 27 '06 #5
There are a few other little things to translate. In C++, we are used to
thinking in terms of DLL's and LIBs. No such thing exists in the .NET world.
Intead, we get 'assemblies' which are normally DLL's. There is no need to
include a link library to access the functionality. Intead, a 'reference' is
added to the solution. Since you are supplying all of the code in multiple
projects, the easiest thing may be to have a single solution with all of
your projects and then have your project include references to where the
namespaces for your redundantly named classes reside.
--
Richard Lewis Haggard
www.Haggard-And-Associates.com

"schizoid_man" <an*****@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Arne Vajhøj wrote:
schizoid_man wrote:
The problem is - what if I have a really large project? It is
concievable that different classes could have the same method name(s)
and the same input parameters.

How would I control which methods are the ones used? Since there is no
method 'filtering' in the include file, would this be done simply by
using whichever objects have instantiated the respective
classes/methods?

Classes with different names but same method signatures = no problem.

Classes with same name and same method signatures = problem, which
can and should be solved by using namespaces.
Yes, I suppose only the first situation should arise. Same names and
method signatures for different classes is probably poor design in any
case.
BTW, I do not think that is really so different from C++. Sure
you will not get a compile error if only you include one declaration
in the header files. But you will eventually get a link error.
Thanks for the help.
Aug 27 '06 #6

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

Similar topics

9
by: Daniel Moree | last post by:
I'm using MS VC++ 6.0 I'm working on a big project. I've currently have several files for this project. Here's the problem. I have one header file phead.h I have two code files main.cpp and...
10
by: Tim Mulholland | last post by:
My company is about to begin working on an ASP.NET application. There are going to be two primary developers working on this project. It will be a fairly deep project (lots of lines of code) but...
5
by: vj | last post by:
Hi all, I am using C++Builder-5. I want to run multiple cpp files at the same time. If I use the C++Builder for running a cpp file (i.e., I just double click the cpp file, it then opens in the...
1
by: Ranginald | last post by:
Hi, I have an asp.net project and I am in the process of trying to make it into a truly object-oriented project -- as I have just learned I cannot have multiple codebehind files in a single...
27
by: Smithers | last post by:
Until now I have worked on small teams (1-3 developers) and we've been able to stay out of each others way. Now I'm about to start work on a project that will have 5 developers. I would appreciate...
2
by: Sam | last post by:
Hi All, I have a solution which consists of multiple projects and each of these projects has their own app.config file. The problem is that all of my projects in the solution pull keys from the...
2
by: SharpCoderMP | last post by:
i'm trying to embed multiple program icons in my executable. the only way so far i managed to do that is to embed native win32 resource file with multiple icons. it works, but... when i create a...
3
by: Claudio Pacciarini | last post by:
Hi everyone, I have a question about .NET code sharing and reuse, and also about application design best practices / guidelines. Currently, we have many different .NET projects in source...
6
by: Joseph Geretz | last post by:
I have the following class which I am serializing and passing back and forth between my Web Service application and the client. public class Token : SoapHeader { public string SID; public...
0
by: Sells, Fred | last post by:
the short answer is a file is a module; therefore to 'include' access to 'myclass' in file xyz.py from another file called 'abc.py' you would put this in abc.py import xyz #note no '.py' x =...
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: 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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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.