interface

C# using Generics both in the Interface and its implementor class

半世苍凉 提交于 2020-02-15 08:44:08
问题 I want to create an interface that works for all the IComparable types. For example public interface SortAlgorithm<T> where T : System.IComparable<T> { List<T> Sort(List<T> input); } And I want its implementors to be generic as well with the same specification I provide in the interface. Like the example below public class InsertionSort<T> : SortAlgorithm<T> Here is my purpose for doing this. I want all my sorting algorithms to work with all types that implements the IComparable interface.

In Typescript how to fix Cannot set property 'first' of undefined

狂风中的少年 提交于 2020-02-12 02:58:25
问题 I'm trying to set a the sub property first that is defined in the Name interface but when do so I always get an error for example: interface Name{ first: string, last:string, } class Person{ private name:Name public setName(firstName, lastName){ this.name.first = firstName; this.name.last = lastName; } } var person1 = new Person(); person1.setName('Tracy','Herrera'); When running it i get the error: Cannot set property 'first' of undefined Any one have an idea to work this out? 回答1: Class

tkinter widget interface interactive button

纵饮孤独 提交于 2020-02-08 04:26:29
问题 I am very new to interactive python programming so please bear with me. I am using PyCharm with Python 3.3. I am attempting to build the following: I want to generate an a function that pulls up interactive window with two text input fields and two buttons: -The first button (START) runs a small text-search function (which I already wrote and tested), while the second button (QUIT) will quit the app. -The first text input field takes a string to be searched (ex: "Hello Stack World"), while

Java: Alternative to Multiple inheritance

点点圈 提交于 2020-02-07 05:48:04
问题 I have a class A that has to extend class B and C which are both provided by 3rd party and I don't have a control of them. Since Java doesn't support multiple inheritance. Using interface wouldn't help in my case since I do want to inherit the base classes' implementation and I don't want to copy their code over to my class, or I'll need to be aware of all their coming changes. What would be the best way to accomplish this need? All suggestion will be much appreciated! 回答1: class A class B2

Interface variables - sliders affecting sliders

China☆狼群 提交于 2020-02-06 04:31:21
问题 Let's say I have two sliders on my interface. Slider one goes from 0-500 and slider two goes from 0-100. Is there anyway of setting it so that the value of slider one influences the possible values for slider two. So if I set slider one to 500, slider two can only be values from 0-30, for example. Alternatively it would not necessarily have to be a slider affecting another slier, it could be a button. So if I have buttons A and B, if I select A the slider can be 0-10 but if I select B only 20

Serialize list of interfaces using XML Serialization

核能气质少年 提交于 2020-02-05 06:26:30
问题 I have the class below which I need to serialize using the XML Serializer I know that the XML serializer does not like interfaces However, our coding standards normally involve always coding to interfaces not concrete classes I thought of a way to be able to stream this list without changing the types which would cause many compilation issues, as well as breaking our standards My idea is to have a property which reads the Meters list and casts to concrete classes then to totally ignore meters

How to get all network interface name and information in c++

放肆的年华 提交于 2020-02-05 03:44:49
问题 Is it possible to get all network interfaces(whether up or down ) name and available information in Linux using c++? I mean a program that only uses API to get interface's name. Does "ioctl" print down interfaces? 回答1: Not specially for C++, but you can use the C API and the 'getifaddrs' function to do so: http://man7.org/linux/man-pages/man3/getifaddrs.3.html 来源: https://stackoverflow.com/questions/18495619/how-to-get-all-network-interface-name-and-information-in-c

Interface implements overriding its own methods to create an object of itself as DEFAULT

白昼怎懂夜的黑 提交于 2020-02-04 20:46:09
问题 I've read many threads with questions which looks like questions I am going to ask. However, I can not find satisfactory answers which could be applied to my questions, since there are more than one fold in my questions, seperated in three aspects. This is the interface SubtitleDecoderFactory in https://github.com/google/ExoPlayer/blob/release-v2/library/core/src/main/java/com/google/android/exoplayer2/text/SubtitleDecoderFactory.java As I understand, an interace is abstraction and can not

Contractual async and sync code

孤人 提交于 2020-02-04 01:39:10
问题 There are a lot of questions asking whether to mix async and sync code. Most answers say it is a bad idea to expose sync wrappers for async methods, and to expose async wrappers for sync methods. However, none of the answers address the specific scenario where you HAVE to mix async and sync code, and how to avoid common pitfalls that arise because of it. See the following example: class Program { static void Main(string[] args) { IContract signatory = new SyncSignatory(); signatory

login page and navigation bar

强颜欢笑 提交于 2020-02-02 13:19:28
问题 When first launching the apps, I want it to show a button to log in. After successfully logged in, I want the app to show a tab bar view.. So does this mean that I need to set my app delegate to point to the UITabBarController? How can I do this? 回答1: I load my UITabBarController in the app delegate, so before adding the login screen the last bit of the applicationDidFinishLaunchingWithOptions looks like this: [window addSubview:tabcontroller.view]; [window makeKeyAndVisible]; To add a view