interface

Interface inheritance: is extending properties possible?

烂漫一生 提交于 2019-12-09 04:18:00
问题 I want to do this: interface IBase { string Property1 { get; } } interface IInherited : IBase { string Property1 { get; set; } } So that IInherited would have the inherited property Property1 with added functionality to allow set . Is that possible? What's the syntax? EDIT: please notice I put the word "inherited" in bold face. I am asking specifically about inheriting the property, not hiding it behind a new one. 回答1: If the fact that the only way to do this is by using the new keyword

How to add a delegate to an interface C#

╄→гoц情女王★ 提交于 2019-12-09 04:08:47
问题 I need to have some delegates in my class. I'd like to use the interface to "remind" me to set these delegates. How to? My class look like this: public class ClsPictures : myInterface { // Implementing the IProcess interface public event UpdateStatusEventHandler UpdateStatusText; public delegate void UpdateStatusEventHandler(string Status); public event StartedEventHandler Started; public delegate void StartedEventHandler(); } I need an interface to force those delegates: public interface

What is the super class for all the interfaces in java [closed]

爷,独闯天下 提交于 2019-12-09 04:00:33
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . In java, I know that super class of all "classes" is "Object" class. My doubt is,what is the super class for all the "interfaces" in java. 回答1: Interfaces are not classes. Therefore, an interface cannot have a superclass, and your question is essentially invalid. Is Interface a class? Is a Java interface an

Correct design for entity classes. Need recommendations

霸气de小男生 提交于 2019-12-09 03:41:39
问题 For example, I have entity class User : public class User { private long id; private String name; // setters and getters } Next, I add new entity class: Comment public class Comment { private long id; private String comment; // setters and getters } Next, I can add more and more entity classes. And, at this moment I think: I can/must bind/connect in logical structure my entity classes or no? What I mean? I try explain: Point 1: All this classes: User , Comment and more other - POJO . Idea 1:

LINQ against two different data contexts using interfaces

孤街醉人 提交于 2019-12-09 03:24:32
问题 This is the continuation of my question asked here. Brief summary: I have two different databases with minimal changes (one table and foreign keys to it are missing in one table) and I want my import utility that uses Linq-To-Sql to be able to populate both databases with data without duplication of the logic. My first approach was to use dynamic storing two different database contexts in a single variable, but this approach did not work and I was recommended to use interfaces for this

Interface observer pattern: null object reference

◇◆丶佛笑我妖孽 提交于 2019-12-09 03:05:29
Not sure what's wrong with my observer pattern: I have defined my interface as: public interface OnBackFilterPressListener { public ArrayList<FoodType> filterFoodType (); } When I press the back button, I want the listener to be activated - all this code is in my activity class: back.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onBackFilterPressListener.filterFoodType(); } } In my adapter class, I have the following code: public class RandomRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements SearchActivity

Type parameter 'T' has the same name as the type parameter from outer type '…'

杀马特。学长 韩版系。学妹 提交于 2019-12-09 02:20:12
问题 public abstract class EntityBase { ... } public interface IFoobar { void Foo<T>(int x) where T : EntityBase, new(); } public interface IFoobar<T> where T : EntityBase, new() { void Foo(int x); } public class Foobar<T> : IFoobar, IFoobar<T> where T : EntityBase, new() { public void Foo(int x) { ... } void IFoobar.Foo<T>(int x) { Foo(x); } } I get a compiler warning: Type parameter 'T' has the same name as the type parameter from outer type '...' I tried doing: void IFoobar.Foo<U>(int x) { Foo

Why do we have to name interface method parameters?

℡╲_俬逩灬. 提交于 2019-12-09 02:10:23
问题 In C# we have to name the parameters of a method of an interface. I understand that even if we didn't have to, doing so would help a reader understand the meaning, however in some cases it's not really needed: interface IRenderable { void Render(GameTime); } I would say the above is as readable and meaningful as the below: interface IRenderable { void Render(GameTime gameTime); } Is there some technical reason why names for parameters of methods on an interface are required? It's worth noting

What instantiate-able types implementing IQueryable<T> are available in .Net 4.0?

时光总嘲笑我的痴心妄想 提交于 2019-12-09 02:07:05
问题 Within the context of C# on .Net 4.0, are there any built-in objects that implement IQueryable<T> ? 回答1: IQueryable objects are produced by Queryable Providers (ex. LINQ to SQL, LINQ to Entities/Entity Framework, etc). Virtually nothing you can instantiate with new in the basic .NET Framework implements IQueryable. IQueryable is an interface designed to be used to create Queryable providers, which allow the LINQ library to be leveraged against an external data store by building a parse-able

need of Static variables and their overhead on jvm

江枫思渺然 提交于 2019-12-09 01:21:37
问题 As per the concept about static members, they are created/loaded into the memory when there is first call made to its class. And they are common among all instances of that class. Means they are not re-created or re-itialized etc. In addition, They can be accessed by the class name only. There is no need to create object for that class just to access them. Now my questions are; Whether static members ever be in memory till the application is running? even if all the instances of that class