using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{

    struct Complex
    {
        double r;
        double i;
        public Complex(double rt, double it)
        {
            r = rt;
            i = it;
        }
        public static void print(Complex c)
        {
            Console.WriteLine("Value of r= " + c.r + "Value of i= " + c.i);
            Console.ReadLine();
        }
        public static Complex add(Complex a, Complex b)
        {
            return new Complex(a.r + b.r, a.i + b.i);
        }
        public static Complex sub(Complex a, Complex b)
        {
            return new Complex(a.r - b.r, a.i - b.i);
        }
        public static Complex mul(Complex a, Complex b)
        {
            return new Complex(a.r * b.r, a.i * b.i);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Complex complex1 = new Complex(1.1, 1.2);
            Complex complex2 = new Complex(1.1, 1.2);
            Complex complex3;
            complex3=Complex.add(complex1, complex2);
            Complex.print(complex3);
        }
    }
}

You need a main function. Above is the modified console application.

On Fri, Jul 10, 2009 at 2:12 AM, thread <yaniv...@gmail.com> wrote:

>
> hello all,
> i'm trying to use this code in MainClass but nothing works:
>        struct Complex
>        {
>                double r;
>                double i;
>                public Complex(double rt,double it)
>                {
>                        r = rt;
>                        i = it;
>                }
>                public static Complex add(Complex a,Complex b)
>                {
>                        return new Complex(a.r+b.r,a.i+b.i);
>                }
>                public static Complex sub(Complex a,Complex b)
>                {
>                        return new Complex(a.r-b.r,a.i-b.i);
>                }
>                public static Complex mul(Complex a,Complex b)
>                {
>                        return new Complex(a.r*b.r,a.i*b.i);
>                }
>        }
>
> does anyone have an idea for it?
>



-- 
Regards
Jay Dan

Reply via email to