forloop.htm
Objectives:
  • Increment (++) operators
  • Constructor / Destructor
  • try /catch block
using System;
// csc forloop_1.cs
class forloop
{
public forloop(){ Console.WriteLine( "constructor evolved");}
~forloop() { Console.WriteLine("destrctor evoked");}

public int wl(int n)
{

for(int i = 0; i < n; i++)
{
Console.Write("L="+ i + ",");

}

Console.WriteLine();
return n;
}
}
class test
{

static void Main()
{
forloop w = new forloop();
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" );

}

}
}