03.01.2015 Views

C# 5.0 Programmer's Reference

Visual Studio 2013 C# 5.0 Programmer's Reference

Visual Studio 2013 C# 5.0 Programmer's Reference

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Exercises ❘ 25<br />

6. Repeat Exercise 2 for the program you built in Exercise 5. What do you think will happen<br />

when you run the program What actually happens<br />

7. Repeat Exercise 3 for the program you built in Exercise 5. What do you think will happen<br />

when you run the program What actually happens<br />

8. You’ve probably got the hang of this by now, but if you want to try WPF (or if you skipped<br />

the previous exercises because you care about only WPF), repeat Exercise 1 with a WPF<br />

application named WPFShowArgs. Place a ListBox named argsListBox on the form and<br />

set its Height and Width properties to Auto. Click the form (not the ListBox) to select it.<br />

In the Properties window, click the Event button (the lightning bolt) and double-click in<br />

the box to the right of the Loaded event. Add the bold code in the following snippet to the<br />

form’s Load event handler.<br />

private void Window_Loaded(object sender, RoutedEventArgs e)<br />

{<br />

foreach (string arg in Environment.GetCommandLineArgs())<br />

argsListBox.Items.Add(arg);<br />

}<br />

What do you think will happen when you run the program Run the program to find out.<br />

Then define the command-line arguments as described in Exercise 1 and run the program<br />

again. What actually happens<br />

9. Repeat Exercise 2 for the program you built in Exercise 8. What do you think will happen<br />

when you run the program What actually happens<br />

10. Repeat Exercise 3 for the program you built in Exercise 8. What do you think will happen<br />

when you run the program What actually happens<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!