Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Difference between the syntax of C# form and console apps

r63

Elite Diviner
Joined
Jan 27, 2012
Messages
417
Reaction score
63
Just wondering, is the syntax for C# console apps any different from C# form applications?
 
Joined
Aug 6, 2005
Messages
546
Reaction score
293
Just wondering, is the syntax for C# console apps any different from C# form applications?
The syntax itself is the same (C# is C#...), but for windows form apps you have to use other parts of the .net framework (namespace System.Windows.Forms etc).
 
Google my name...
Joined
Nov 9, 2011
Messages
483
Reaction score
151
The syntax itself is the same (C# is C#...), but for windows form apps you have to use other parts of the .net framework (namespace System.Windows.Forms etc).

This hit the nail on the head practically.

To memory (I don't use the forms often and haven't used C# in about a year) it has a slightly different syntax for things like if statements as well. But mostly it is the normal C# syntax.

All the best,
Richard Komakech.
 
Joined
Jun 8, 2007
Messages
1,985
Reaction score
490
it has a slightly different syntax for things like if statements as well. But mostly it is the normal C# syntax.

All the best,
Richard Komakech.
Are you sure the if statements aren't just formatted in a way you dont normally see in console applications? It seems very out-of-this-world if one of the major functionalities of C# is different in form applications rather than console applications.. In fact, that's too low for Microsoft- I don't believe it. I mean, C# isn't bad because of it's language design... I highly doubt it has such an ugly blemish as you describe. What I do believe is that C# form applications (those made in Microsoft's programs) contain more proprietary parts of the .NET framework than typical console applications would. Which is why most ppl who use C# use microsoft's tools, and most ppl who use C# aren't really coding in C#- but well, instead just C# syntax so to use the .NET framework and functionalities. Those people would very likely code things like "if" statements differently than those who use C# to code console applications. I don't believe the syntax of the language in two different environments is actually different, though. But I dont know- never used Microsoft's visual C# programs.
 
• ♠️​ ♦️ ♣️ ​♥️ •
Joined
Mar 25, 2012
Messages
909
Reaction score
464
in fact windows forms and console apps are the same in entire. u can access the console class from any windows form too but it wont arive anywhere. the syntax is full equal, since .net is a whole bunch of system both things use.

a big difference is console apps use static output libs, u call the Console class methods statically so.
Code:
Console.WriteLine("Hello World");

otherwise in forms, u call the instance of any form and modify any properties of any controls to change them, like a label on your form.
Code:
// Designer of Form1 contains and builds:
Form1 = new Form();
Label1 = new Label();
// ...
public partial class Form1()
{
  public Form1()
  {
    InitializeComponents();
    this.Label1.Text = "Hello World";
  }
}

events / eventhandlers, generics, reflections, all kind of systems are completely equal in both ways. its just getting tricky for u when u work with different threads and want to access the content of your form from another thread (cuz its not static), like when building callbacks from any seperate algorithms that run in extra threads. in console applications u can simply call Console.Write to say any thing is done from any extra thread in your callback, while changing properties of form controls will force u to transmit the form instance and the thread synchronisation context to allow modifications over threads.
 
Back
Top