C # Since its birth, we have taken the lead of the family, and have thousands of pets in one, and are still famous . Net framwork A member of the family is naturally noble. Big brother in programming Java After more than a decade of development, it has been robust and powerful. Open Source Community Of SSH ( Struts + spring + hibernate ) Framework to make J2EE With unparalleled charm. Versatility, portability, and scalability are well supported. Every time we learn SSH I will give you a general idea later. Why? . Net There is no such excellent framework. Therefore. Net Fans also developed their own Sh ( Nspring + nhib.pdf ). But the two frameworks and . Net The programming style is always out of place. This is just something copied. But we do not need to be too pessimistic, C #3.0 The emergence of this feature has brought us a lot of new features. As for what new features, I will introduce them one by one.
First new feature: automatically generate attributes
Generally, we need to writeGET/SetTo provide external access and operations for attributes. For example:
Code
Public Class Userinfo
{
String Username;
String Password;
Public Username
{
Get { Return Username ;}
Set {Username = Value ;}
}
Public Password
{
Get { Return Password ;}
Set { Return Password = Value ;}
}
}
We always envyEclipseIsJavaProperty is automatically generatedGeter/seterMethods, althoughVisual StudioIt can also be similar, but it is not convenient to use, especially when a class has many attributes, write theseGET/SetThe method is really annoying. WhileC #3.0Finally let us get rid of this nightmare, and you will find that it is a feature of the language itself, comparedJavaOfGeter/seterThe method should be simpler, simpler, and more natural. Microsoft has made a lot of effort in terms of details.
Okay. Let's see how to use it.C #3.0To compile the above class.
Code
code highlighting produced by actipro codehighlighter (freeware)
http://www.CodeHighlighter.com/
--> Public class userinfo
{< br> Public string username { Get ; set ;}< br> Public string password { Get ; set ;}< BR >}< br>
We can find that this is too easy. We only need to addGET/SetThe two keywords are used to write a few rows.Code.. Net framworkIt will automatically generate its private attributes for us. Using it is the same as using the above class.
Code
Userinfo=NewUserinfo ();
Userinfo. Username="Test ";
Userinfo. Password="Test ";
Now, we canJavaFans show off. Haha, just kidding.