C # Generic Type: I'm totally disappointed ....!!!!

Source: Internet
Author: User

Okay, let's get frustrated first, and then start this post.
I finally pulled Whidbey Alpha from eMule yesterday, GB. After installing it today, I can't wait to try the generic type in C #. However, I want to cry! This function is too weak. How long will it take? There will be no new things to play with the C # generic model. This is for me to switch from C ++ to C, where can this be called generic !! In addition to creating a container (call! It is useless even if it is a container. When I first saw the generic constraint on msdn, I felt bad. It is said that the CLR supports generics, but the actual implementation of things, the function is not necessarily better than Java (the efficiency is C # generics is much higher, I will try again next time ). The most exaggerated is that the instantiated type must have a non-argument constructor!
Sigh... Bruce Eckel's words are really pertinent.

I am so sad that I can't write any more. First, I will test my first C # Generic Model.ProgramPost it out. I will write a detailed article about take a close look at C # generics.

Using system;

Namespace consoleapplication1
{
InterfaceItest
{
Void testmethod ();
}

Class Testtype : Itest
{
// Public testtype (int I ){}
Public void testmethod ()
{
Console . Writeline ("testing ");
}

}


ClassTest <T> where T: Itest , New ()
{
Public test (int I)
{
Datat = new T ();
Dataint = I;
}
Public void Foo ()
{
Datat. testmethod ();
}
Public t datat
{
Get {return datat ;}
}
Public int dataint
{
Get {return dataint ;}
}
Private t datat;
Private int dataint;
}
Class Class1
{
[ Stathread ]
Static void main (string [] ARGs)
{

Test < Testtype > Ti = new Test < Testtype > (4 );
// Console. writeline (TI. datat );
Ti. Foo ();
Console . Writeline (TI. dataint );
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.