Add the first C# Class:

  1. using the "Solution Explorer" Find the Northwind startup project.
  2. Right click on the project name and select "Add" then select "New Folder".
  3. Change the name of the new Folder to "Exercises".
  4. Right click the new folder you just created and select "Add" then select "New Item"
  5. From the "Add New Item" screen, select Class
  6. Name your new Class MyFirstClass and click the "Add" button.

Your new Class supposed to look like this code :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Northwind.Exercises
{
     class MyFirstClass
     {
     }
} 

Add your first Method:

  1. Add to your new class A Run Method

Your new Class supposed to look like this code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Northwind.Exercises
{
    class MyFirstClass
    {
        public void Run()
        {

        }
    }
} 

Add a message

  1. Add the code to show a "Hello C#" message to the end user

Your new Class supposed to look like this code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Northwind.Exercises
{
    class MyFirstClass
    {
        public void Run()
        {
            System.Windows.Forms.MessageBox.Show("Hello C#");
        }
    }
} 
  1. Using the "Solution Explorer" open the "Views" folder at the startup project.
  2. open the "ApplicationMdi.cs".
  3. Add a new menu called Exercises.
  4. Add a new entry called Hello C#.
  5. Double click the new entry.
  6. In the Code Behind Call the new class your just created

Your menu enter Code Behind should look like that :

        private void helloCToolStripMenuItem_Click(object sender, EventArgs e)
        {
            new Exercises.MyFirstClass().Run();
        } 

Build and Run


Help us improve, Edit this page on GitHub
or email us at info@fireflymigration.com