Hello everyone!
I have a few (possibly several) questions about C#. I've been attempting to learn C# for close to a month now, and while I understand some basic things and some of the syntax, I'm finding it difficult to learn just how and where to use commands, and why one would use them, etc,.
For example, let me list the following example:
namespace My.Program
{
public class Test
{
static void Main()
{
string nmeStrng = "[Blank]";
Console.WriteLine("" + nmeStrng +", please enter your name:")
nmeStrng = Console.ReadLine();
Console.WriteLine("" + nmeStrng + "."
Console.ReadLine();
}
}
}
Okay...so, I know what the writing/user input commands are and how to use them, but what about setting up the "Main()" part of the program? What's the difference between "static void Main()" and "public void/public static void Main()"? How does a person know when, where and why to use either of those three?
And what about something like this? (Copied example)
//Import the references
using System;
using System.Windows.Forms;
using System.Drawing;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
//Create a namespace for our program
namespace JELProductions.WindowsForm
{
//Create a class to contain the form
public class AForm : Form
{ //Main program code
static void Main()
{
Application.Run(new AForm());
}
//Create a Window
public AForm()
{
Text = "TestApp";
}
protected override void OnPaint(PaintEventArgs pea)
{
pea.Graphics.DrawString("C# is a fun language.", this.Font,
Brushes.Black, 0, 0);
}
}
}
How does that program know to access the "protected override void OnPaint" function if it's not being called in the Main()? I mean, really? Am I missing something obvious here?
That's really all I've got for now, but I'm sure there's going to be plenty of other questions in the future. I've been trying to learn this for a while now, so any help is GREATLY appreciated!
-CoffeeCoder
Formerly known as Yodaman Jer