u r creating class object in same class.see the code and run it
namespace ConsoleApplication1
{
public class MyClass
{
public void divide()
{
int x = 0;
int result = 0;
try
{
result = 5 / x;
}
catch (DivideByZeroException de)
{
Console.WriteLine(de.Message);
}
Console.WriteLine("Result {0}", result);
}
}
class Program
{
static void Main(string[] args)
{
MyClass m = new MyClass();
m.divide();
}
}
}
i hope this will help u
On 8/11/09, Raghupathi Kamuni <[email protected]> wrote:
>
> using System;
> public class MyClass
> {
>
> void divide()
> {
> int x = 0;
> int result =0;
> try
> {
> result = 5/x;
> }
> catch(DivideByZeroException de)
> {
> Console.WriteLine(de.Message);
> }
>
> Console.WriteLine("Result {0}",result);
>
> }
> public static void Main()
> {
> MyClass m = new MyClass();
> m.divide();
> }
>
> }
>
> DivideByZeroException Class
> http://msdn.microsoft.com/en-us/library/system.dividebyzeroexception.aspx
>
>
>
>
> On Mon, Aug 10, 2009 at 10:14 PM, thread <[email protected]> wrote:
>
>>
>> Hi all,
>>
>> i dont know if this problem is common for cerain calcualtion or maybe
>> something was incorrect with the apperoach but when i calculate for
>> example 5/0
>> i'm getting some garbage instead of a warning about the zero devision
>> what am i doing wrong
>> any idea?
>>
>
>