Re: How to pass information, classes between forms in Windows Application mode
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Wed, 23 Jul 2008 19:17:50 +0100
raylopez99 <raylopez99@xxxxxxxxx> wrote:
<snip>
OK, see below for an example, but keep in mind your console mode
example fails to be instructive for several reasons: (1) it's console
mode not Forms. Totally different, and if you don't see it that way no
use further discussing this issue.
In that case I guess it's the end of the discussion. Forms apps aren't
nearly as different as you seem to believe, and until you accept that I
suspect this conversation really won't go anywhere. In particular,
these things don't change at all when considering Forms apps:
1) There still has to be an entry point - a Main method
2) The Main method still has to be in a type, because all methods are
within types in C#.
3) Partial classes work the same with forms as with any other classes.
4) There's still no such thing as a forward declaration.
5) Pass-by-reference vs pass-by-value works exactly the same way
in WinForms apps as console apps (and any other C# code)
6) Class and variable declarations in C# work exactly the same way
in WinForms apps as console apps (and any other C# code)
7) Scoping and access rules in C# work exactly the same way
in WinForms apps as console apps (and any other C# code)
Are you seeing a pattern?
Forms apps are certainly more *complicated* than Console apps, because
there's all the designer code involved, and basically a lot more
*stuff*. But the language itself doesn't change.
Forms have certain 'entry points'
and certain quirks that must be obeyed. (2) you use the convention of
static void Main() being 'nested' inside a class, which does not show
how the nested class is seen by another class in a different
translation unit.
Please show who you could possibly have the Main method *not* in a
class or struct.
It goes to the heart of why form Form2:Form1 cannot
'see' Class0 unless Class0 is declared public *twice*, not just nested
with keyword public, but in the declaration public Class0 myClass0;
before the class Class0 is defined.
That's not declaring a class. That's declaring a variable called
myClass0, of *type* Class0. The sooner you understand that, the better.
Unless you use the "class" keyword, you're *not* declaring a class.
Perhaps, and I could use your input, the problem 'earlier' in this
thread is that classes 1 and 2, which are not nested, are not
explictly declared prior to the Form1 contructor with the keyword
'public', and, though in their respective modules I declare them as
'public', this makes them 'private' somehow when declared within Form
1 without the keyword 'public' (that is truly shocking if true).
Thanks for your help so far. I look forward to your reply.
If you would post a short but *complete* program which demonstrates
something strange.
You did not even attempt to answer my question "Perhaps, and I could
use your input".
No, but I said what you needed to do for me to answer it: post a short
but complete program. When you do that, I'll answer your question.
Shows me you're still unaware of the complexity of
Forms, and the 'entry points' that I alluded to (which I would hazard
you don't even know exist).
Oh you really are priceless. Did you behave the same way with your
teachers at school? Yes, I'm very aware of entry points, thank you.
But, since a teacher learns from his
students almost as much as the students learn from the teacher, I will
give you a short example of this phenomena--and I encourage you to
replicate this problem in "Forms", not console mode.
Oh look, it's another incomplete example. See
http://pobox.com/~skeet/csharp/incomplete.html
(Hint: It's perfectly possible to post a complete WinForms program if
you really want to. You just haven't done so. It would be far simpler
to stick to console apps though.)
If you understand this simple example you're half way towards
understanding the problem in this thread.
I understand everything that occurs in the C# language in this thread.
I don't understand some of what you're trying to communicate because
you persist in talking inaccurate terms (such as "forward references")
and posting incomplete programs.
If you'd post a complete program which either you believe goes against
something I've said, or which contains some aspect you don't
understand, we may be able to make some progress.
--
Jon Skeet - <skeet@xxxxxxxxx>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
.
- Follow-Ups:
- References:
- How to pass information, classes between forms in Windows Application mode
- From: raylopez99
- Re: How to pass information, classes between forms in Windows Application mode
- From: Jon Skeet [C# MVP]
- Re: How to pass information, classes between forms in Windows Application mode
- From: raylopez99
- Re: How to pass information, classes between forms in Windows Application mode
- From: Jon Skeet [C# MVP]
- Re: How to pass information, classes between forms in Windows Application mode
- From: raylopez99
- Re: How to pass information, classes between forms in Windows Application mode
- From: Jon Skeet [C# MVP]
- Re: How to pass information, classes between forms in Windows Application mode
- From: raylopez99
- Re: How to pass information, classes between forms in Windows Application mode
- From: Jon Skeet [C# MVP]
- Re: How to pass information, classes between forms in Windows Application mode
- From: raylopez99
- How to pass information, classes between forms in Windows Application mode
- Prev by Date: Re: Getting information from IEnumerable
- Next by Date: Re: Binding Control (Non-List) to Specific DataTable Row and Colu
- Previous by thread: Re: How to pass information, classes between forms in Windows Application mode
- Next by thread: Re: How to pass information, classes between forms in Windows Application mode
- Index(es):
Relevant Pages
|