From: nicol on 14 Jun 2010 09:55 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***** { } }
From: Willem van Rumpt on 14 Jun 2010 10:34 On 14-6-2010 15:55, nicol wrote: > 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. -- Willem van Rumpt
From: nicol on 14 Jun 2010 11:01 On Jun 14, 6:34 pm, Willem van Rumpt <wdotvandotrumpt(a)skoutsoftdotcom> wrote: > On 14-6-2010 15:55, nicol wrote: > > > > > 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. > > -- > Willem van Rumpt thanks the error solved with your help . but i really don't know where i must use override ?
From: Peter Duniho on 14 Jun 2010 11:28 nicol wrote: > thanks the error solved with your help . but i really don't know > where i must use override ? Amazingly enough, the MSDN web site, to which I referred you earlier, provides the information you seek: http://msdn.microsoft.com/en-us/library/ebca9ah3.aspx I wasn't kidding before. You will find your C# programming activities go a lot more smoothly if you would learn to look things up on MSDN. Pete
From: J.B. Moreno on 14 Jun 2010 11:40 nicol <nicol.young20(a)gmail.com> wrote: > 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). -- J.B. Moreno
|
Next
|
Last
Pages: 1 2 Prev: Asynchronous Socket programing and Thread Pool Next: Passing type as a parameter |