now i remember why i abandoned 'c' for basic and pascal, data handling.
what i want to do is fairly simple, but when appled to standard data is fairly usual in a business program.
i want to input a 'number' from the console and manipulate it.. thus...
in basic:
input "please enter a number:";a
input "please enter a number:";b
print "the sum of ";a;" plus ";b;" is "; a + b
i have this so far in c# (console app)
static
void Main(string[] args){
string userName,numberA, numberB; Single a, b; Console.WriteLine("hello "); Console.Write("what be your name:");userName =
Console.ReadLine(); Console.Write(userName ); Console.Write(" please enter a number:");a =
Console.ReadLine(); // this does not work, i intend to supliment it some how with// a function to input numberA as string then convert to single 'a'
// but i have yet to find a complete reference to c#
Console.Write ("please enter another number:");
b = Console.ReadLine(); //same as for 'a' unless there is a simple way to read in a number
Console.writeline("their sum is {0}", a + b);
Console.Write(" press enter to exit");
Console.Read();
}
help.. is there a definative reference, the online stuff and the how do i is not much help,
i have what i thought was an instruction manual, ";visual c# from novice to professional" and it simply does not help. any one have a suggestion for a reference. I am a writer of sorts and i assure you i am working on a if you did this in 'basic' you should try this in 'c#' wicki.
/meow/
my new web site is (some now done in visual studio) at:
mrzkitten.org

string to a number... plus can you simply read a number from standard i/o
Dan Mikkelsen
things i discovered...
one can not just read a number from the standard input, but it is simple to get the number:
in basica:
input "please enter a number ";x
this is what i finally ended up with (close to above)
PeterTPeterT
class Program
{
static void Main(string[] args)
{
float number = InputFloat("Please enter a number: ");
Console.WriteLine("You entered the number: " + number);
}
static float InputFloat(string prompt)
{
for (;;)
{
Console.Write(prompt);
string input = Console.ReadLine();
float result;
if (float.TryParse(input, out result))
return result;
Console.WriteLine("That is not a number.");
}
}
}