Newbie question, where to put standard code

A

Andrew

I have just started looking at C# coming from a Delphi background. My
question is where do I put my standard code routines.

e.g.
In Delphi I had my standard often used string handling routines in
StrTools.pas which I would store in C:\Develop\Delphi7\Standard\Lib folder.
I would then link this unit into any application I was working on and it
would be compiled in.

In C# I can create a StrTools.cs file and place it in
c:\Develop\CSharp\Standard\Lib and then I have to manually add it to any
projects that I am working on.

But is this the best way to go about things? Should all standard misc bits
of code go in their own assembly. How does everyone else organise things
like this?

Also does this mean the assembly is then open to be used by other third
party applications? I some cases I would not want this e.g. standard code
for encrypting passwords.
 
A

Aboulfazl Hadi

Hi
In C#, you can implement class library and then add its references to
your project.
So, you follow the following steps:
1. Create New Class Library
2. Implement your classes and organize those into namespaces
3. Add refrence to any project that is needed your class.

Best Regards,
A.Hadi
 
J

Joanna Carter [TeamB]

"Andrew" <[email protected]> a écrit dans le message de [email protected]...

|I have just started looking at C# coming from a Delphi background. My
| question is where do I put my standard code routines.
|
| e.g.
| In Delphi I had my standard often used string handling routines in
| StrTools.pas which I would store in C:\Develop\Delphi7\Standard\Lib
folder.
| I would then link this unit into any application I was working on and it
| would be compiled in.
|
| In C# I can create a StrTools.cs file and place it in
| c:\Develop\CSharp\Standard\Lib and then I have to manually add it to any
| projects that I am working on.

Hi Andrew

For a start, you really need to look at what the framework classes provide;
to use your example, there are a lot of methods in the string class that
would replace your Delphi code. You must also consider the difference in
nature of .NET strings: they are unicode, they are immutable, don't try
building strings in a tight loop as they can be slow. You should also look
at the StringBuilder class.

| But is this the best way to go about things? Should all standard misc
bits
| of code go in their own assembly. How does everyone else organise things
| like this?

You would normally develop your own assemblies for your own utility library
stuff, but be aware that, unlike Delphi, every method has to be a part of a
class, there is no such thing as a freestanding function or procedure, nor
global variables.

I will reiterate; please take the time to find out what the framework
libraries have to offer before you bring in a whole load of your (possibly
unsuitable) Delphi code.

I have been working n .NET, translating my OPF and MVP frameworks and have
thrown out about 80% of the original Delphi code in some cases, due to the
facilities provided in .NET.

| Also does this mean the assembly is then open to be used by other third
| party applications? I some cases I would not want this e.g. standard code
| for encrypting passwords.

In .NET, all code can be disassembled to near its original C#/Delphi/VB,
unless it is obfuscated.

We, in the UK Developers Group, are just about to embark on a series of
sessions on starting with .NET. Whether you come from a Delphi or C#
background, keep an eye out for the upcoming meetings. www.ukbug.co.uk

Joanna
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top