Syronix
04-06-2010, 06:55 AM
I'm not sure if I can post this here but I figured it was worth a try. I just started learning C#
and was wondering if anyone could help me with this latest console project I am working on
I'm stuck on Line 58 because I can't figure out how to reference <System.Windows.Forms.dll>
Here's my code
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace BasicIO
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("***** Basic Console I/O *****");
GetUserData();
FormatNumericalData();
Console.ReadLine();
}
static void GetUserData()
{
// Get name and age.
Console.Write("Please enter your name: ");
string userName = Console.ReadLine();
Console.Write("Please enter your age: ");
string userAge = Console.ReadLine();
// Change echo color, just for fun.
ConsoleColor prevColor = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Yellow;
// Echo to the console.
Console.WriteLine("Hello {0}! You are {1}.", userName, userAge);
// Restore previous color.
Console.ForegroundColor = prevColor;
}
// now we make use of some format tags.
static void FormatNumericalData()
{
Console.WriteLine("The value 99999 in various formats:");
Console.WriteLine("c format: {O:c}", 99999);
Console.WriteLine("d9 Format: {O:d9}", 99999);
Console.WriteLine("f3 format: {O:f3}", 99999);
Console.WriteLine("n format: {O:n}", 99999);
// Notice that upper- or lowercasing for hex
// determines if letter are upper- or lowercase.
Console.WriteLine("E format: {O:E}", 99999);
Console.WriteLine("e format: {O:e}", 99999);
Console.WriteLine("X format: {O:X}", 99999);
Console.WriteLine("x format: {O:x}", 99999);
}
void DisplayMessage()
{
// Using string.Format() to format a string literal.
string userMessage = string.Format("100000 in hex is {O:x}", 100000);
// You would need to reference System.Windows.Forms.dll
// in order to compile this line of code!
System.Windows.Forms.MessageBox.Show(userMessage);
}
}
}
If anyone can help that would be great =D
and was wondering if anyone could help me with this latest console project I am working on
I'm stuck on Line 58 because I can't figure out how to reference <System.Windows.Forms.dll>
Here's my code
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace BasicIO
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("***** Basic Console I/O *****");
GetUserData();
FormatNumericalData();
Console.ReadLine();
}
static void GetUserData()
{
// Get name and age.
Console.Write("Please enter your name: ");
string userName = Console.ReadLine();
Console.Write("Please enter your age: ");
string userAge = Console.ReadLine();
// Change echo color, just for fun.
ConsoleColor prevColor = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Yellow;
// Echo to the console.
Console.WriteLine("Hello {0}! You are {1}.", userName, userAge);
// Restore previous color.
Console.ForegroundColor = prevColor;
}
// now we make use of some format tags.
static void FormatNumericalData()
{
Console.WriteLine("The value 99999 in various formats:");
Console.WriteLine("c format: {O:c}", 99999);
Console.WriteLine("d9 Format: {O:d9}", 99999);
Console.WriteLine("f3 format: {O:f3}", 99999);
Console.WriteLine("n format: {O:n}", 99999);
// Notice that upper- or lowercasing for hex
// determines if letter are upper- or lowercase.
Console.WriteLine("E format: {O:E}", 99999);
Console.WriteLine("e format: {O:e}", 99999);
Console.WriteLine("X format: {O:X}", 99999);
Console.WriteLine("x format: {O:x}", 99999);
}
void DisplayMessage()
{
// Using string.Format() to format a string literal.
string userMessage = string.Format("100000 in hex is {O:x}", 100000);
// You would need to reference System.Windows.Forms.dll
// in order to compile this line of code!
System.Windows.Forms.MessageBox.Show(userMessage);
}
}
}
If anyone can help that would be great =D