Hi everyone,
I want to build a example about Generics Constraint with the question:
How will the complier catch a error when user input string type but reasonable with int, float, double, long type?
Can you help me this problem?
Many thanks.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Cuong PhamPosted Aug 16, 2013, 3:50 AM
Best wishes for u !
VulpesPosted Aug 16, 2013, 3:13 AM
Iftikar HussainPosted Aug 16, 2013, 1:01 AM
http://www.c-sharpcorner.com/uploadfile/yougerthen/using-icomparable-and-icomparer-to-compare-objects/
Regards,
Iftikar
Iftikar HussainPosted Aug 16, 2013, 12:55 AM
Cuong PhamPosted Aug 16, 2013, 12:28 AM
It means that you can initialize a object with string type, the compile time will catch error.
ex: Create a class Compare two number
and then in Main method:
ObjectClass
ObjectClass
ObjectClass
ObjectClass
but:
ObjectClass
It only supports int, float, long, double.
Iftikar HussainPosted Aug 16, 2013, 12:05 AM
I am not clear about your query. Can you please explain bit more?
Regards,
Iftikar