472,988 Members | 2,900 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

New to C# - basic question

I want to learn C# initially via console applications. I would like to write
some reusable code that I can 'call' in any application. For example, code to
position the cursor and use the various colour attributes wrapping up some of
the methods of the System.Console library.

What I am not clear on is how I can write these methods in a 'standalone'
file so that I can call them in apps with the 'using' statement. I'm a little
confused as to whether I have to have a Main() method in the file containing
my calleable code.

Sorry if this is basic. I'm using Visual C# Express edition.

Thanks
Aug 1 '08 #1
6 926
On Thu, 31 Jul 2008 23:28:01 -0700, Paolo
<Pa***@discussions.microsoft.comwrote:
[...]
What I am not clear on is how I can write these methods in a 'standalone'
file so that I can call them in apps with the 'using' statement. I'm a
little
confused as to whether I have to have a Main() method in the file
containing
my calleable code.
You can create a variety of project types. The three main ones you're
likely to run into are: Windows application; console application; and DLL.

You want to make a DLL (the third type in that list). Then you can add a
reference to that DLL in a project in which you want to use the classes in
that DLL.

Pete
Aug 1 '08 #2
On Aug 1, 1:35 am, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
You want to make a DLL (the third type in that list). Then you can add a
reference to that DLL in a project in which you want to use the classes in
that DLL.
Look for the project of type "Class Library".

Chris
Aug 1 '08 #3
Peter: thanks for that. So I just write my code and save as a DLL and Visual
Studio does all the rest i.e. saves in the correct file format and adds any
specific DLL statements?

I'll test the code in a 'normal' app first then.

"Peter Duniho" wrote:
On Thu, 31 Jul 2008 23:28:01 -0700, Paolo
<Pa***@discussions.microsoft.comwrote:
[...]
What I am not clear on is how I can write these methods in a 'standalone'
file so that I can call them in apps with the 'using' statement. I'm a
little
confused as to whether I have to have a Main() method in the file
containing
my calleable code.

You can create a variety of project types. The three main ones you're
likely to run into are: Windows application; console application; and DLL.

You want to make a DLL (the third type in that list). Then you can add a
reference to that DLL in a project in which you want to use the classes in
that DLL.

Pete
Aug 1 '08 #4
Chris: thanks. Presumably I can include my new class library with the 'using'
statement.

"Chris Dunaway" wrote:
On Aug 1, 1:35 am, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
You want to make a DLL (the third type in that list). Then you can add a
reference to that DLL in a project in which you want to use the classes in
that DLL.

Look for the project of type "Class Library".

Chris
Aug 1 '08 #5
On Fri, 01 Aug 2008 16:49:00 -0700, Paolo
<Pa***@discussions.microsoft.comwrote:
Peter: thanks for that. So I just write my code and save as a DLL and
Visual
Studio does all the rest i.e. saves in the correct file format and adds
any
specific DLL statements?
I don't even recall off the top of my head whether a managed DLL _has_ the
same requirements that a regular Windows DLL does (entry point, unload
function, etc.) But yes, if you set the project type correctly (whether
by selecting the correct project type when you create it, or by changing
the output type in the project properties), you'll get a DLL that you can
then reference from other projects.
I'll test the code in a 'normal' app first then.
That should be fine. Though, it's so easy to set up a DLL in VS, I think
you might as well start with your project as a DLL, and reference it in a
test application.

Pete
Aug 2 '08 #6
On Aug 2, 3:52*am, Paolo <Pa...@discussions.microsoft.comwrote:
Chris: thanks. Presumably I can include my new class library with the 'using'
statement.
Not really. "using" statement has nothing to do with libraries as such
- it deals with namespaces. Often a library contains a single
namespace, but it is merely convention (and not a universal one at
that). To reference a library from your program, you need to add a
project reference in Solution Explorer (right-click on "References"
there, and choose "Add").
Aug 2 '08 #7

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

Similar topics

6
by: pauldepstein | last post by:
I am reading Grimshaw and Ortega's "C++ and Numerical Methods." They construct a vector class which contains the variable vec, a float* variable where the length of the array (number of...
6
by: DH | last post by:
I have a VERY basic question about figuring database size. I've inherited a database which is generally similar to this basic one: Item, Red, Blue, Green, Yellow (text), (int),(int),(int),(int)...
9
by: Malcolm | last post by:
After some days' hard work I am now the proud possessor of an ANSI C BASIC interpreter. The question is, how is it most useful? At the moment I have a function int basic(const char *script,...
4
by: Ramesh | last post by:
hi, Let me ask some basic questions. Can anybody explain me about the following questions: 1. When we have to create sn key? Whenever we compiled Component we have to create or it is a one time...
13
by: Pete | last post by:
I'm cross posting from mscom.webservices.general as I have received no answer there: There has been a number of recent posts requesting how to satisfactorily enable BASIC authorization at the...
5
by: Aussie Rules | last post by:
Hi, Having a mental block on this one. Have done it before but can't rack my brain on how... I have an object, with a bunch on property, and I add that object to a combo box. I want the...
4
by: MikeB | last post by:
I've been all over the net with this question, I hope I've finally found a group where I can ask about Visual Basic 2005. I'm at uni and we're working with Visual Basic 2005. I have some books, ...
1
by: frankhanretty | last post by:
Do I have to install Visual basic on the remote terminals as I did on the server? I have an visual basic 5 application running fine on my client's server and he is now networked. He wants to run the...
4
by: Chris Asaipillai | last post by:
Hi there My compay has a number of Visual Basic 6 applications which are front endeed onto either SQL Server or Microsoft Access databases. Now we are in process of planning to re-write these...
3
by: Scott Stark | last post by:
Hello, I'm trying to get a better handle on OOP programming principles in VB.NET. Forgive me if this question is sort of basic, but here's what I want to do. I have a collection of Employee...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.