This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface IFetchThings<T> { | |
| T Fetch(); | |
| } | |
| public interface ISecureFetchThings<T> : IFetchThings<T> { | |
| T Fetch(); | |
| bool isLoggedOn(); | |
| void logOn(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface IFetchThings<T> where T : Fetched, IFetchable, System.IComparable<T>, new() { | |
| ... | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface IFetchThings<T> where T : class { | |
| T Fetch(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Dictionary<TKey,TValue> { | |
| public void Add (TKey key, TValue value); | |
| public bool ContainsKey (TKey key); | |
| public bool ContainsValue (TValue value); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class simpleExample<T> { | |
| private T myVar; | |
| public T myProp { get; set; } | |
| public T myMethod1() { ... } | |
| public void myMethod2(T arg) { ... } | |
| public T myMethod3(T arg) { ... } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class DocumentFetcher : IFetchThings<Document> { | |
| public Document Fetch() { ... } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ProjectFetcher : IFetchThings<Project> { | |
| public Project Fetch() { ... } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ClientFetcher : IFetchThings<Client> { | |
| public Client Fetch() { ... } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface IFetchThings<T> { | |
| T Fetch(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| IFetchThings fetcher = new ClientFetcher(); | |
| object fetched = fetcher.Fetch(); // object is really a Client (Boxed as an object) | |
| // let's convert the object to a client | |
| Client c = (Client)fetched; // Unbox fetched into Client - performance hit | |
| // the compiler can't see any problem with this | |
| // and it works at run-time | |
| // let's convert the object to a project | |
| Project p = (project)fetched; // Unbox fetched into Project - performance hit |
NewerOlder