Windows Phone 7 offers the ability to write applications using the Silverlight platform, here is the classic Hello World example brought to Windows Phone with C# and Visual Studio 2010 Express for Windows Phone.
Printer Friendly Download Tutorial (365KB) Download Source Code (15.9KB)
Step 1
Start Microsoft Visual Studio 2010 Express for Windows Phone, then Select File then New Project... Select "Visual C#" then "Silverlight for Windows Phone" and then "Windows Phone Application" from Templates, select a Location if you wish, then enter a name for the Project and then click OK, see below:

Step 2
A Windows Phone application Page named MainPage.xaml should then appear, see below:

Step 3
Then from the Windows Phone Controls section in the Toolbox select the Button control:

Step 4
Draw a Button on the Page, see below:

Step 5
Then goto the Properties box and change the Name to HelloWorld and the Content property from Button to "display" without the quotes, see below:

Step 6
Double Click on the Button Control and type in the HelloWorld_Click method:
PageTitle.Text = "Hello World";
See Below:

Step 7
Save the Project as you have now finished the Windows Phone Silverlight application. Select the Windows Phone Emulator option then Select Debug then Start Debugging or click on Start Debugging:

After you do, the following will appear in the Windows Phone Emulator after it has been loaded:

Step 8
Now click where it says "display" and the page title will change to Hello World, see below:

Step 9
You can then Stop the application by selecting the Visual Studio 2010 application window and clicking on the Stop Debugging button:

That was your first simple application for Windows Phone using Silverlight, you may also deploy your application to a Windows Phone 7
device if you wish and run it there.
Try changing the message shown instead of Hello World, or change the Button caption - there is a lot
to learn from this simple example!