Parameter Action in which T3 can be optional

Optional parameters are an attribute of a method or delegate parameter. When you call a signature (method or delegate) that has a known optional parameter at compile-time, the compiler will insert the optional parameter value at the callsite. The runtime is not aware of optional parameters, so you can’t make a delegate that inserts an … Read more

OOP: Which class should own a method? [closed]

subjective 🙂 but honestly, I’d go with the Information Expert Pattern and say something like library.lend(item, patron) The library contains the information about the items it has (perhaps in its catalog). The library lends the item to the patron (which it knows because it registers them) Not sure how your instructor sees this, but this … Read more

Do C# 8 default interface implementations allow for multiple inheritance

Your question is answered by Mads Torgersen in the blog post you linked to: Actually interfaces are still quite far from abstract classes. Classes don’t inherit members from interfaces, so if a class leaves a member M implemented by the interface, the class does not have a member M! It’s like an explicit implementation today; … Read more

“Non-static variable this cannot be referenced from a static context” when creating an object

Make ShowBike.Bicycle static. public class ShowBike { private static class Bicycle { public int gear = 0; public Bicycle(int v) { gear = v; } } public static void main() { Bicycle bike = new Bicycle(5); System.out.println(bike.gear); } } In Java there are two types of nested classes: “Static nested class” and “Inner class”. Without … Read more