interface?!

N

nicol

hi
i have a problem with interface plz help me
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication6
{
class Program
{
static void Main(string[] args)
{
}
}
}
public interface Ishape
{
double masahat();
double mohit();
}
public class point : Ishape
{
private double radiuse;
public point()
{
}
public point(int radiuse_value)
{
Radiuse = radiuse_value;
}
public double Radiuse
{
get
{
return radiuse;
}
set
{
radiuse = value;
}
}
public override double masahat() //*******here has error*****
{
}
}
 
W

Willem van Rumpt

hi
i have a problem with interface plz help me
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication6
{
class Program
{
static void Main(string[] args)
{
}
}
}
public interface Ishape
{
double masahat();
double mohit();
}
public class point : Ishape
{
private double radiuse;
public point()
{
}
public point(int radiuse_value)
{
Radiuse = radiuse_value;
}
public double Radiuse
{
get
{
return radiuse;
}
set
{
radiuse = value;
}
}
public override double masahat() //*******here has error*****
{
}
}

Because there's nothing to override, only to implement.
Write the method as

public double masahat()
{
}

and you're good.

btw:
if this is your actual code, then your next error message will be that
your class doesn't implement method "mohit" of the Ishape interface.
 
N

nicol

hi
i have a problem with interface plz help me
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication6
{
     class Program
     {
         static void Main(string[] args)
         {
         }
     }
}
public interface Ishape
{
     double masahat();
     double mohit();
}
public class point : Ishape
{
     private double radiuse;
     public point()
     {
     }
     public point(int radiuse_value)
     {
         Radiuse = radiuse_value;
     }
     public double  Radiuse
     {
         get
         {
             return radiuse;
         }
         set
         {
             radiuse = value;
         }
     }
     public override double masahat()  //*******here has error*****
     {
     }
}

Because there's nothing to override, only to implement.
Write the method as

public double masahat()
{

}

and you're good.

btw:
if this is your actual code, then your next error message will be that
your class doesn't implement method "mohit" of the Ishape interface.

thanks the error solved with your help . but i really don't know
where i must use override ?
 
J

J.B. Moreno

nicol said:
thanks the error solved with your help . but i really don't know
where i must use override ?

Look at the word "override". That implies that there's an existing
implementation that you do NOT want to use in this case, that you want
to OVERRIDE.

Which means it is never going to apply to an interface, which is all
definition and no implementation (at least in the interface itself).
 
H

Harlan Messinger

nicol said:
thanks the error solved with your help . but i really don't know
where i must use override ?

Whatever documentation you read that told you that such a thing as
"override" exists is likely to be where you will find details on how it
is used. What it didn't tell you is that you would use it for
implementing a method of an interface, because it isn't used for that.
 
N

nicol

Whatever documentation you read that told you that such a thing as
"override" exists is likely to be where you will find details on how it
is used. What it didn't tell you is that you would use it for
implementing a method of an interface, because it isn't used for that.

thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top