java - Limiting type arguments for generics in C# -


I was thinking a lot, but I miss in Java that I can declare a field or parameter as I:

Public Class BarHandler {public class

This may be useful for factory-style systems, where you have to be able to generate new examples of type of example.

I am trying to figure out whether it is analog in C # or it is probably something that is available in Java.

There is a variation of answer 280Z28. I have named the "type" class as "factory" because in my version it's like value instead of type type GetInstance The method displays . It uses 2 general parameters and common barriers to implement the rules in the creator of the original answer for the normal type of type.

  Public abstract class factory & lt; T & gt; {GetInstance T {Public Essentials; } Public Sealed Class IoCfactory & lt; T, TDR, & gt; : Factory and lieutenant; T & gt; Where TDR: T / compiler implies that TDRAT is obtained from T {Public override T gate instance (TODO) TODO: Retrieve example of TDRIV from Spring News, Structures, Unity, etc. like IOC containers. }} Public Sealed Class Trigger Faster & lt; T, TDR, & gt; : Factory and lieutenant; T & gt; Where TDRs: T, new () // compiler has implemented that came out of TDRRD and it has a parasailable constructor (Public Override T Gate Instance) (Return Activator. ક્રેઇટ ઇન્સ્ટન્સ & lt; TDRRead & gt; (); Public Square BarHandler {Public Factory & lt; Foo & gt; FooFactory {Get; set;} Public Processed Process (String XML) {Foo foo = fooFactory.GetInstance (); return foo.Process (xml);}} Class program (String [] args) {barhandler handler = new barhandler (); handler.fufficactue = new activator factor & ft; bar; bar; ! & Lt; / bar & gt; ");}}  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -