public abstract class FormShellApplication<TWorkItem, TShell> : WindowsFormsApplication<TWorkItem, TShell>
where TWorkItem : WorkItem, new()
where TShell : Form
thank you,
-hazz 4 1559
> public abstract class FormShellApplication<TWorkItem, TShell> : WindowsFormsApplication<TWorkItem, TShell> where TWorkItem : WorkItem, new() where TShell : Form
The where keyword is used to apply restrictions to the kinds of types that
client code can use for type arguments when it instantiates a class. In the
your example the "TWorkItem : WorkItem, new()" constraint restricts the TWorkItem
generic parameter to inherit from the WorkItem class and have a default,
parameterless constructor. The "where TShell : Form" constraint restricts
the TShell generic parameter to inherit from the Form class.
Anders Norås http://dotnetjunkies.com/weblog/anoras/
It constrains the generic parameters to specific types. TWorkItem, for
example, must derive from the calss WorkItem and provide a parameterless
constructor and TShell must derive from the class Form
"hazz" <hazz@sonic_net> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
public abstract class FormShellApplication<TWorkItem, TShell> :
WindowsFormsApplication<TWorkItem, TShell>
where TWorkItem : WorkItem, new()
where TShell : Form
thank you,
-hazz
I see. So this works hand in hand with generics then, if I understand this
correctly now.
Thank you Daniel.
-Greg
"Daniel O'Connell [C# MVP]" <onyxkirx@--NOSPAM--comcast.net> wrote in
message news:eh*************@TK2MSFTNGP11.phx.gbl... It constrains the generic parameters to specific types. TWorkItem, for example, must derive from the calss WorkItem and provide a parameterless constructor and TShell must derive from the class Form
"hazz" <hazz@sonic_net> wrote in message news:%2****************@TK2MSFTNGP14.phx.gbl... public abstract class FormShellApplication<TWorkItem, TShell> : WindowsFormsApplication<TWorkItem, TShell> where TWorkItem : WorkItem, new() where TShell : Form
thank you, -hazz
Thank you Anders.
Since generics allow any object...if that is a correct statement, then the
where statements are a way of specifying that in this case, only certain
objects will work and are allowed.
-hazz
"Anders Norås" <an**********@objectware.no> wrote in message
news:66*************************@news.microsoft.co m... public abstract class FormShellApplication<TWorkItem, TShell> : WindowsFormsApplication<TWorkItem, TShell> where TWorkItem : WorkItem, new() where TShell : Form
The where keyword is used to apply restrictions to the kinds of types that client code can use for type arguments when it instantiates a class. In the your example the "TWorkItem : WorkItem, new()" constraint restricts the TWorkItem generic parameter to inherit from the WorkItem class and have a default, parameterless constructor. The "where TShell : Form" constraint restricts the TShell generic parameter to inherit from the Form class.
Anders Norås http://dotnetjunkies.com/weblog/anoras/
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Steven T. Hatton |
last post by:
If a header is not necessarily a source file, and the sequences delimited by
< and > in header names aren't necessarily valid source file names, what
exactly is a header?
--
p->m == (*p).m == p.m...
|
by: Steven T. Hatton |
last post by:
This is something I've been looking at because it is central to a currently
broken part of the KDevelop new application wizard. I'm not complaining
about it being broken, It's a CVS images. ...
|
by: slugster |
last post by:
Hi,
i originally posted this via another portal, but after giving it time
to propagate it still hasn't shown up. My apologies for the
multiposting.
This might be a very simple question, but i...
|
by: ypjofficial |
last post by:
Hello all,
I have written a class with many private data members.and i am putting
it in a separate dll file.
Now when i link that file while writing my main program
module,natuarally i have to...
|
by: Bob Hairgrove |
last post by:
Consider the classic clone() function:
class A {
public:
virtual ~A() {}
virtual A* clone() const = 0;
};
class B : public A {
public:
| |
by: nospam_timur |
last post by:
Let's say I have two files, myfile.h and myfile.c:
myfile.h:
int myfunction(int x);
myfile.c:
#include "myfile.h"
|
by: grizggg |
last post by:
I have searched and not found an answer to this question. I ran upon
the following statement in a *.cpp file in a member function:
static const char * const pacz_HTMLContentTypeHeader =...
|
by: mosfet |
last post by:
HI,
when trying to compile an embedded version of STL called ustl on win32
platform I get the following error :
/// Returns the minimum of \p a and \p b
template <typename T1, typename T2>...
|
by: Hongyu |
last post by:
Hi,
I am a newbie in C++. I saw a code like the below and don't understand
it.
class A
{
public:
A();
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |