using System;
// csc do_while.cs
class dowhile
{
public dowhile(){ Console.WriteLine( "constructor evolved");}
~dowhile() { Console.WriteLine("destructor evoked");}
public int wl(int n)
{
int i = 0;
do
{
Console.Write("L="+ i + ",");
i++;
}
while(i < n);
Console.WriteLine();
return i;
}
}
class test
{
static void Main()
{
dowhile w = new dowhile();
Console.Write("Enter a number :" );
string str;
str= Console.ReadLine();
try
{
//try block if correct wont show
int num = Int32.Parse(str);
w.wl(num);
Console.WriteLine("OK, carried On");
}
catch(Exception ex)
{
Console.WriteLine("looks like you missed something :"+ str + " you may use ex to complete result" );
}
}
} |