Click here to Skip to main content
15,894,106 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
public abstract class BasePage<T> : Page where T : class
Posted
Updated 2-Jan-14 2:36am
v4
Comments
Kornfeld Eliyahu Peter 2-Jan-14 8:38am    
It seems like a syntax error?
Can you elaborate what you looking for?
Can you show the context in which this line is written?
Karthik_Mahalingam 2-Jan-14 8:41am    
where you are facing the issue?
please add more info..
post your code, where u r getting error...
♥…ЯҠ…♥ 2-Jan-14 8:43am    
Do you get error? I hope you wont
Sumit Bhargav 2-Jan-14 8:46am    
I am not getting any error.I am trying to implement Unity Container and for that i have to register my class in the OnpreInit event of the default page and for that i am creating a class which will inherit the page class.Hence i am trying to understand the meaning of this code.

public : public access modifier so you can use this anywhere which references this class.
abstract : a placeholder for implementation and not creatable directly (you must implement a inherited one from this first).
class : class definition (as opposed to interface, struct etc.)
BasePage<t></t> : a generic object based on the definition of T
:Page : the above is inherited from the Page definition
where T :class : a modifier for the generic definition of T so it can only accept objects (so you can't have BasePage<int></int> etc.)
 
Share this answer
 
Comments
Karthik_Mahalingam 2-Jan-14 9:29am    
5, GOOD
Mehdi Gholam 2-Jan-14 11:16am    
Thanks!
Quote:
Can anyone please tell the meaning of undermentioned line in c#?

The line:
C#
public abstract class BasePage<T> : Page where T : class

Means that you create an abstract class[^] that derives from Page. The BasePage class has one Generic Type Parameter[^], T, and the where T : class means that when you create a new instance of BasePage, the generic type parameter must be a reference type[^], not a value type[^]. If you pass a value type as generic type parameter, you get a compiler error.
 
Share this answer
 
v2
Comments
Karthik_Mahalingam 2-Jan-14 9:30am    
NEAT EXPLANATION.
Thomas Daniels 2-Jan-14 9:37am    
Thank you!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900