Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Delphi to C#

2 views
Skip to first unread message

Godfrey

unread,
Mar 14, 2007, 5:47:01 AM3/14/07
to
Hi

I am learning C#. Are there any books/sites for persons with delphi
experience moving to C#?.

I have one question which is bugging me perhaps someone can answer.

In Delphi, if you want to reference another form or its components you just
added that form name to the uses section
in the form you are working (Delphi even added it automatically for you. Go
Delphi). Then you can work that form
or any of its components from another form.

How do I do this in C#?. I tried making the component public but I cannot
seem to get it right.

Thanks


Craig Stuntz [TeamB]

unread,
Mar 14, 2007, 10:27:18 AM3/14/07
to
Godfrey wrote:

> In Delphi, if you want to reference another form or its components
> you just added that form name to the uses section in the form you are
> working (Delphi even added it automatically for you. Go Delphi).
> Then you can work that form or any of its components from another
> form.
>
> How do I do this in C#?.

The C# equivalent of Delphi's "uses" is using. So you can say:

using Other_Namespace;

If Other_Namespace contains an instance variable for the other form,
you can then work with that instance in your code.

Remember that namespaces and files aren't the same thing. You specify
the namespace, not the filename.

--
Craig Stuntz [TeamB] · Vertex Systems Corp. · Columbus, OH
Delphi/InterBase Weblog : http://blogs.teamb.com/craigstuntz
Want to help make Delphi and InterBase better? Use QC!
http://qc.borland.com -- Vote for important issues

Marc Rohloff [TeamB]

unread,
Mar 14, 2007, 9:37:45 PM3/14/07
to
On Wed, 14 Mar 2007 11:47:01 +0200, Godfrey wrote:

> In Delphi, if you want to reference another form or its components you just
> added that form name to the uses section
> in the form you are working (Delphi even added it automatically for you. Go
> Delphi). Then you can work that form
> or any of its components from another form.
>
> How do I do this in C#?. I tried making the component public but I cannot
> seem to get it right.

Delphi does a few things automatically for you (by default):
1) Components are public by default
2) It creates a public variable
3) At startup it creates an instance of every form and assigns it to
the variable.

You can do each of these yourself in c# (Edit the main() routine) but
they are all considered to contribute to bad program design.

--
Marc Rohloff [TeamB]
marc -at- marc rohloff -dot- com

Godfrey

unread,
Mar 16, 2007, 3:26:41 AM3/16/07
to
Where do I insert this in my code?

Thanks

"Craig Stuntz [TeamB]" <craig_...@nospam.please [a.k.a. acm.org]> wrote
in message news:45f7...@newsgroups.borland.com...

Craig Stuntz [TeamB]

unread,
Mar 16, 2007, 10:20:28 AM3/16/07
to
Godfrey wrote:

> Where do I insert this in my code?

Using goes at the top of the file:

http://msdn2.microsoft.com/en-us/library/sf0df423.aspx

--
Craig Stuntz [TeamB] · Vertex Systems Corp. · Columbus, OH
Delphi/InterBase Weblog : http://blogs.teamb.com/craigstuntz

Useful articles about InterBase development:
http://blogs.teamb.com/craigstuntz/category/21.aspx

0 new messages