C # Basics Summary

Source: Internet
Author: User

Only member variables and member methods in 1.CLASS

 classRectangle {//member Variables        Doublelength; Doublewidth;       //member Methods         Public voidacceptdetails () {length=4.5; Width=3.5; }         Public DoubleGetarea () {returnLength *width; }         Public voidDisplay () {Console.WriteLine ("Length: {0}", length); Console.WriteLine ("Width: {0}", width); Console.WriteLine ("Area : {0}", Getarea ()); }    }    

Variables in 2.CLASS: global variables

Variables in methods: local variables

member functions and member variables in the same class can be operated on.

3. Using another class requires new instantiation, using member variables: New strength name. variables

Use member functions: New strength name. Method ()

When the main function in the same class calls other methods: This is new, and the method can call itself.

The member variable in 4.CLASS {get;set;}, after new, can be assigned to read and assign values, new instance names. member variables, if only get is read-only when declared.

Represents, attribute xxx can be either get or set.
If it is only set, it can only be provisioned and vice versa.
The old version of the. NET Framework cannot be omitted for attributes, which must be done:
int Adminid = 0;
Public Adminid
{
Get{return Adminid;}
Set{adminid=value;}
}
And now the version can be omitted, just need:
public adminid{get;set;} The meaning of the delegate is the same as defining the attribute of the class Admin Adminid

5. Value type allocation in the stack compile time good memory, such as: class string multiple memory, the use of the class will not change the value of the memory address (unless the actual memory value is changed), if added in the parameters of the method (ref variable) will become a reference type
6. The reference type assignment has only one memory in the heap, such as int char, which changes the value of the memory address when used to a class.
7. The value type does not need to be instantiated, the field property method is static and does not need to be instantiated
8. The parameters in the method are generally input, the Null method has no return value, and the type method generally returns a value.
9.struct is a value type
Column:
struct books{   publicstring  title;     Public string author;     Public string subject;     Public int book_id;};  
struct is used for a one-time function class for large extensible functions
A static class cannot be inherited, and only one address is not instantiated, similar to a struct.
1. Function overloading: Same as method name but different parameters or different number of parameters.

C # Basics Summary

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.