Moving from Delphi to C# - Need Guidance

G

Guest

Hi All,

I have been a longtime Delphi programmer/fan, and until now have not seen
the need to convert to C# and Visual Studio. I know that many programmers
have made the switch over the past few years so I am in hopes of a little
guidance.

Now, one of the key components I use in many of my projects has shifted
their development focus to C#, almost exclusively.

So, with admitted reluctance, I am now going to make the jump for at least
this one project. If I like it then I will probably stay with VS just
because it seems to get new technology sooner.

Two generic questions:
* What are some recommended references for learning the language
differences and converting code? I have ordered a book from Amazon (C# for
Delphi Programmers) and done a lot of googling. I do not need/want programs
to convert my stuff (like turnsharp) - I want to learn to do it myself.
* What were your biggest obstacles when you moved from Delphi to C#, and
how did you overcome them?


One specific question:
* Many of my apps work with local data (mybase/briefcase data) that is
generated from TClientDataSet. Using SaveToFile and LoadFromFile the apps
can quickly load a saved copy of the DataSet in instances when querying the
database is not really necessary or practical. Can someone show me a simple
example of saving and loading local data from a file to a Data Set?

Thanks for your Help!
Dave
 
F

Frank Rizzo

Dave said:
Hi All,

I have been a longtime Delphi programmer/fan, and until now have not seen
the need to convert to C# and Visual Studio. I know that many programmers
have made the switch over the past few years so I am in hopes of a little
guidance.

Probably, not what you want to hear, but why not just use Delphi for .NET?
 
L

Liz

you might want to look at the docs at MSDN for DataTable.ReadXml overloads
.... I don't recall the Delphi stuff but you can do what you want to do in C#
.... many ways ...
 
G

Guest

Frank Rizzo said:
Probably, not what you want to hear, but why not just use Delphi for .NET?

I did consider that, but the core component I am using is all done in c# now
and I assumed it would be easier to do my development in the same.

I can see the assemblies in Delphi for .Net, but I have not taken the time
to see just what I need to do for the components to show up. I will look
into that more.

I still think I want to learn C# as a go forward solution, but if I can make
it work in Delphi.net that might be a viable short-term alternative.
 
G

Guest

Dave said:
I have been a longtime Delphi programmer/fan, and until now have not seen
the need to convert to C# and Visual Studio. I know that many programmers
have made the switch over the past few years so I am in hopes of a little
guidance.

Now, one of the key components I use in many of my projects has shifted
their development focus to C#, almost exclusively.

So, with admitted reluctance, I am now going to make the jump for at least
this one project. If I like it then I will probably stay with VS just
because it seems to get new technology sooner.

Two generic questions:
* What are some recommended references for learning the language
differences and converting code? I have ordered a book from Amazon (C# for
Delphi Programmers) and done a lot of googling. I do not need/want programs
to convert my stuff (like turnsharp) - I want to learn to do it myself.
* What were your biggest obstacles when you moved from Delphi to C#, and
how did you overcome them?

You need to learn two new things:
* the .NET class library
* the C# language

You could consider learning the first by starting to use Delphi.NET !

Your code will work perfectly with .NET assemblies compiled from C#.

Then start with C# language in more simple programs in parallel
with that.

I will recommend Processinal C# by Wrox. It is more C++/Java/VB6
oriented than Delphi, but I think an experienced programmer in any
language will find the book easy to read.
One specific question:
* Many of my apps work with local data (mybase/briefcase data) that is
generated from TClientDataSet. Using SaveToFile and LoadFromFile the apps
can quickly load a saved copy of the DataSet in instances when querying the
database is not really necessary or practical. Can someone show me a simple
example of saving and loading local data from a file to a Data Set?

I think the .NET way of that will be to save/load DataSet to/from a
XML file.

Arne
 
G

Guest

Liz said:
you might want to look at the docs at MSDN for DataTable.ReadXml overloads

I will check out the ReadXML and see if that will work for me. I do not see
a binary equivalent for ReadXML. I know in Delphi that choosing XML as the
format for the local mybase file was a major performance hit.

How is the performance of ReadXML in C#? Without a binary version I guess
there is not much to compare it with.

Thanks for the info,
Dave
 
F

Frank Rizzo

Dave said:
I did consider that, but the core component I am using is all done in c# now
and I assumed it would be easier to do my development in the same.

That does not matter. All the .NET languages compile to IL and so is
your component. Delphi will see it just fine.

If you wish to see your c# component in Delphi, download Reflector,
download the FileDisassembler plugin for it. Load your core component
into and dump it out using the Delphi language filter.
 
G

Guest

Dave said:
I will check out the ReadXML and see if that will work for me. I do not see
a binary equivalent for ReadXML. I know in Delphi that choosing XML as the
format for the local mybase file was a major performance hit.

How is the performance of ReadXML in C#? Without a binary version I guess
there is not much to compare it with.

If data is so huge that performance is an issue, then you will
probably need to consider alternatives to both XML *and* DataSet.

But there are alternatives.

Arne
 
G

Guest

Arne Vajhøj said:
You could consider learning the first by starting to use Delphi.NET !

Your code will work perfectly with .NET assemblies compiled from C#.

Then start with C# language in more simple programs in parallel
with that.

I think I will go this route. Having trouble getting the components to show
up in the palette at this point - but I will figure it out. I can find the
assemblies and add them, but the components do not show up.

Thanks for the recommendation on the book too - I will pick it up.

Take care,
Dave
 
J

James Crosswell

Dave said:
Hi All,

I have been a longtime Delphi programmer/fan, and until now have not seen
the need to convert to C# and Visual Studio. I know that many programmers
have made the switch over the past few years so I am in hopes of a little
guidance.

Now, one of the key components I use in many of my projects has shifted
their development focus to C#, almost exclusively.

So, with admitted reluctance, I am now going to make the jump for at least
this one project. If I like it then I will probably stay with VS just
because it seems to get new technology sooner.

Two generic questions:
* What are some recommended references for learning the language
differences and converting code? I have ordered a book from Amazon (C# for
Delphi Programmers) and done a lot of googling. I do not need/want programs
to convert my stuff (like turnsharp) - I want to learn to do it myself.
* What were your biggest obstacles when you moved from Delphi to C#, and
how did you overcome them?


One specific question:
* Many of my apps work with local data (mybase/briefcase data) that is
generated from TClientDataSet. Using SaveToFile and LoadFromFile the apps
can quickly load a saved copy of the DataSet in instances when querying the
database is not really necessary or practical. Can someone show me a simple
example of saving and loading local data from a file to a Data Set?

Hey David,

I made the move a couple of years ago (after having programed with
Delphi from version 1 right through to version 2006) and never looked
back. Visual Studio 2005 is just so much slicker than Delphi ever was
and the .NET platform is seeing an exponential amount of innovation
(pretty much ever since MS pinched Anders from the Borland crew
actually)... not to mention the absolutely gigantic community of .NET
developers compared to Delphi.

In any case, that's all a bit off topic. Generally speaking C# is a
pretty easy transition from Delphi - they're both object oriented
languages that use interfaces, polymorphism and all the other general
nuts and bolts that you find in any modern language.

Some things you'll probably miss and scratch your head over for a bit:

- DataModules don't exist in C#, so you'll need to use Static classes
(or at least static properties of classes that contain a static instance
of that class) to share stuff between multiple other classes/forms. That
means less hooking stuff up at design time between different forms and a
central DataModule (in fact, by less I mean none here) and more plugging
stuff together in code... something I actually found made my apps much
more stable and resistent to change (usually if anything gets broken
that way you find out at build time with a compiler error/warning -
where in Delphi a reference would just "magically" get removed behind
the scenes and you wouldn't realize till run time).

- The data binding mechanism in .NET will be new if you're coming from
Delphi, but is superior. You don't need "Data Aware" components in .NET
- you can hook pretty much any property of any component up to any
vaguely data like list of objects (or even a single object)... which
makes data binding quite a bit more flexible.

Some things you'll want to read up on, since these are concepts that
don't really exist in Delphi:

- The difference between value and reference types and in particular the
consequences of this as it relates to boxing and unboxing

- Writing CLS compliant code (if you'll be mixing languages )

- Delegates... these kind of exist in Delphi in the form of method
pointers, however in .NET they have a special use with the event keyword
(which restricts the operators that can be used) and with anonymous
methods (which are really useful and which don't exist in Delphi - or
didn't when I left the language) and also with Async processing... which
brings me to :

- Async processing and Threads (certainly concepts that exist in Delphi
but handled a bit differently in .NET and so easy to do that it's worth
reading the 5 minute explanation you'll find doing a quick search on
Google for these keywords in conjunction with "C#" and "Tutorial" or
something.

- Generics... I can't think of a world without generics anymore - way
too useful to pass up.

- the params keyword (for use with the last parameter of a method)

- Indexers (the equivalent of Delphi default properties - nothing fancy
or new but you need to know what they're called to find them in the docs)

- The sealed and internal keywords

- preprocessing directives like #error and #warning are quite useful

- The IDisposable interface (as opposed to Finalizers) and the object
lifecycle (since you don't control this directly as you do in Delphi)

- The .NET class library in general (the Configuration namespace,
String.Format, etc. - all sorts of basic plumbing that you'll need to
learn by just stumbling across it basically, looking at examples that
you find on the internet, reading stuff like MSDN Mag or watching videos ).

There's quite a lot of material to learn but coming from Delphi your
well placed to learn it, and the more I learn the more I wonder why I
left it so long to take the plunge!

Hope this helps.

Best Regards,

James Crosswell
Microforge.net LLC
http://www.microforge.net
 
L

Liz

I will check out the ReadXML and see if that will work for me. I do not
see
a binary equivalent for ReadXML.

it's not in a sealed class ... ;) .. actually, I think you can specify a
binary SerializationFormat .. which may be new to ADO.NET 2.0 ... or may
only work as it's supposed to in 2.0

something like:

DataTable t = new DataTable();
t.RemotingFormat = SerializationFormat.Binary

so ... my recollection (vague) is that you you'll need to instantiate a
BinaryFormatter and a FileStream, pass the Stream to the Formatter with your
DataTable and call the Serialize method on the Formatter ....

of course none of this has anything to do with .ReadXml .... but it does
have to do with persisting a DataTable locally (or non-locally) .... try it
.... let us know
I know in Delphi that choosing XML as the
format for the local mybase file was a major performance hit.

yah ... well, efficiency is not the XML calling card ...
How is the performance of ReadXML in C#? Without a binary version I guess
there is not much to compare it with.

I haven't pushed the envelope so it's been fine; sounds like you might have
to put a little additional work in beyond tbl.ReadXml ....
 
G

Guest

Frank Rizzo said:
If you wish to see your c# component in Delphi, download Reflector,
download the FileDisassembler plugin for it. Load your core component
into and dump it out using the Delphi language filter.

I need to play with this more. With Reflector/FileDisassembler I can
generate source files for the assemblies, but all the generated .pas files
seem to contain errors. I get "System.InvalidOperationException: Expression
stack is empty at offset 0006" in every file.

I will play with some variations of settings to see if I can get meaningful
files out of it.

Thanks for pointing me towards Reflector,
Dave
 
A

ABC

So, with admitted reluctance, I am now going to make the jump for at least
this one project. If I like it then I will probably stay with VS just
because it seems to get new technology sooner.


I still think I want to learn C# as a go forward solution, but if I can make
it work in Delphi.net that might be a viable short-term alternative.


If you want to learn C# as a "go forward solution", then its not with
reluctance that you make this jump. You are just a troll seeking
affirmation of what you have already decided to do.





On Mon, 8 Oct 2007 15:09:02 -0700, Dave Wright <Dave
 
J

James Crosswell

ABC said:
If you want to learn C# as a "go forward solution", then its not with
reluctance that you make this jump. You are just a troll seeking
affirmation of what you have already decided to do.

Dude, yeah right... he's reluctant to give up a 5 year plus investment
in a whole bunch of (till now) really useful knowledge cause he's a troll?

Some people amaze me.

Best Regards,

James Crosswell
Microforge.net LLC
http://www.microforge.net
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

ABC said:
If you want to learn C# as a "go forward solution", then its not with
reluctance that you make this jump. You are just a troll seeking
affirmation of what you have already decided to do.

What is your problem ?

Arne
 

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

Similar Threads


Top