Search Results

Search found 2 results on 1 pages for 'tyrone302'.

Page 1/1 | 1 

  • Why can't I call methods within a class that explicitly implements an interface?

    - by tyrone302
    Here's the story. I created and interface, IVehicle. I explicitly implemented the interface in my class, Vehicle.cs. Here is my interface: Interface IVehicle { int getWheel(); } here is my class: class Vehicle: IVehicle { public int IVehicle.getWheel() { return wheel; } public void printWheel() { Console.WriteLine(getWheel()); } } Notice that "getWheel()" is explicitly implemented. Now, when I try to call that method within my Vehicle class, I receive an error indicating that getWheel() does not exist in the current context. Can someone help me understand what I am doing wrong?

    Read the article

  • Does Java have "properties" that work the same way properties work in C# (see the body of my text)?

    - by tyrone302
    In C#, you can use properties to make a data field publicly accessible (allowing the user to directly access it), and yet retain the ability to perform data validation on those directly-accessed fields. Doese Java have something similar? For Instance, suppose there exists a C# class with the following implementation(see below): public class newInt{ public newInt(){...} public int x{ get{ return this.x } set{ this.x = isValid(value) } } } private static int isValid(int value){...} This definition in the class allows the user to "naturally" use the data field 'x' when retrieving values from it and assigning values to it. Below is how it would be used in main. public class Test{ public static void main(String[] args){ newInt a = new newInt(); a.x = 50; int b = a.x; } } The question is... can java do this as well? if so, what is it called?

    Read the article

1