Add the first C# Class:
- using the "Solution Explorer" Find the Northwind startup project.
- Right click on the project name and select "Add" then select "New Folder".
- Change the name of the new Folder to "Exercises".
- Right click the new folder you just created and select "Add" then select "New Item"
- From the "Add New Item" screen, select Class
- 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:
- 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
- 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#");
}
}
}
Menu Item
- Using the "Solution Explorer" open the "Views" folder at the startup project.
- open the "ApplicationMdi.cs".
- Add a new menu called Exercises.
- Add a new entry called Hello C#.
- Double click the new entry.
- 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