Prev | Current Page 761 | Next

Gurdy Leete and Mary Leete

"Microsoft Expression Blend Bible"

If you add another dot at the end of Now, IntelliSense suggests more possibilities.
One of these possibilities is the ToString() method. The final code in this example is:
MyTextBlock.Text = System.DateTime.Now.ToString();
You need to add the parentheses at the end since ToString is a method that is called. Some methods
require that you add values, variables, or even other methods as arguments, but in this case
ToString doesn??™t require arguments.
551
Writing Code 20
FIGURE 20.7
Visual Studio??™s IntelliSense offers you a list of valid options when adding code.
If you test your project by pressing F5, when you press the button in your window, you get the
date and time in the form 2/23/2007 23:47:43 PM. (Yes, it??™s late at night.)
If you just wanted the date and not the time, you could remove the time by adding another period
before the semicolon, and choose Remove from the options. When you type the open parenthesis,
a tooltip appears that describes what arguments are required for the method, as shown in Figure
20.8. It even offers different variations of arguments that you can use. By clicking the up or down
arrows you can sort through the different possibilities, choosing the one that best suits your needs.


Pages:
749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773