当前位置:网站首页>C # related knowledge points
C # related knowledge points
2022-06-13 07:06:00 【AndroidOrCSharp】
attribute
about class Get some private fields in , To limit the value assigned to it by an external class , Access private fields through properties
class getPrivate
{
private string _name; // Field private
public string Name
{
get { return _name + 'a'; }// read-only : Contains only get Read and write : Also include get and set
set { _name = value; }// Just write : Contains only set
} attribute , public But you still need to rely on entity fields
}
String.Empty and " " and null
String.Empty and " " Will allocate a space on the stack , What is saved is a heap with a length of 0 Memory address of
null Does not open up memory space on the heap
ref and out
ref: Pass values by referencing types , What is returned is the variable after the operation , Must pass a variable with a value
out: Can be null
virtual: Virtual functions
Virtual functions are not statically compiled during compilation , Its relative address is uncertain , It will dynamically determine the function to be called according to the runtime object instance
Subclass inherits parent , If you declare a class ( That is, the parent class ) This function is virtual Embellished , First, find out whether this class has overridden or redeclared this method .
There are methods that execute subclasses , If not, you will find the parent class layer by layer , Until you find the parent class that has overridden the method , Then execute this method .
abstract: Abstract method
An abstract method must be an abstract class , Abstract classes don't have to have abstract methods
Abstract class cannot be instantiated , Abstract methods have no concrete implementation
Can't use sealed Modifier to modify the abstract class , Because the two modifiers have opposite meanings . sealed Modifiers prevent classes from being inherited , and abstract Modifier requires the class to be inherited .
Abstract methods cannot be used static or virtual modification , Subclasses must override the abstract methods of the parent class
Because abstract classes cannot be instantiated , So call non abstract methods in abstract classes , Subclasses should inherit abstract classes , Then instantiate the subclass to call the non abstract method of the parent class
override:
You cannot override non virtual or static methods . Override base method must be virtual、abstract or override( Methods that have been rewritten can be rewritten again ).
Out of commission new、static or virtual Modifier modify override Method .
Overriding a property declaration must specify exactly the same access modifier as the inherited property 、 Type and name , And the overridden attribute must be virtual、abstract or override.
Interface:
Interfaces are also declarative , It didn't come true , But unlike the abstract method , Subclasses implementing interfaces must completely override interface members , Subclasses inherit from abstract classes only by overriding abstract methods .
Programming is more standardized , decoupling
The difference between static variables and non static variables
1. Memory allocation
Static variables are used during application initialization , It exists in memory , It doesn't die until the program of the class it belongs to ends ;
Non static variables need to be instantiated before allocating memory .
2. Life cycle
The static variable lifetime is the lifetime of the application ;
The existence period of a non static variable depends on the existence period of the instantiated class .
3. Call mode
Static variables can only be passed through “ class . Static variable name ” call , An instance of a class cannot call ;
Non static variable when the class of the variable is instantiated , It can be accessed directly through the instantiated class name .
4. How to share
Static variables are global variables , Shared by instance objects of all classes , That is, an instance changes the value of a static variable , Other instances of the same kind read the changed value ;
Variables are nonlocal variables , Not shared .
5. access
Static members cannot access non static members ;
Non static members can access static members .
The fewer static members you declare, the better , Compare memory .
6. Static methods cannot be overridden
All members of a static class must be static .
partial: classification
Will class 、 The definition of structure or interface is split into two or more source files , Add... Before class declaration partial Key words can be used .
When compiled, it will be merged into one class
async and await
The two are generally used together ,async Indicates that you want to execute... Asynchronously , Execute to await Will call back the child thread , The execution of the child thread will not continue until it is completed await After that , This program may be executed by the sub thread or the main thread .
Lazy loading
Lazy loading is actually delayed loading , That is, load the object when it needs to be used .
It can reduce the interaction with data sources ( The amount of data, not the number of interactions )
Now use include Instead of
Interface
Make the program Cleaner 、 leaner 、 Easier to design and maintain 、 Easier to enhance
The database lock
Possible effects of concurrency :
1. Lost update : Multiple transactions update the same row at the same time ;
2. Dirty reading : The data in the modification process is read ;
3. Inconsistent analysis ( It can't be read repeatedly ): Read transactions , The row search criteria that match the read criteria have been changed ;
4. Fantasy reading : Read transactions , Rows that meet the read criteria are deleted or inserted ;
1. Pessimistic Concurrency : Use locks to protect data . Used in environments where lock consumption is lower than the cost of rolling back transactions ;
2. Optimistic concurrency control : No lock is generated during concurrency , Check the user data after reading the data , Determine whether there is an error , Roll back the transaction . For environments with less data contention .
1. Shared lock (S) : Read the generated lock , Prevent other transactions from modifying it ;
2. Update lock (U) : It can prevent deadlock , Between shared locks and exclusive locks , Compatible with shared locks , Incompatible with exclusive lock .
3. Exclusive lock (X) : Used for data addition, deletion and modification . Data cannot be modified or read during locking ( stay nolock Or dirty reading when the read isolation level is not committed )
OOA/OOD and UML
OOA It refers to object-oriented analysis ,OOD It refers to object-oriented design .
UML Unified Modeling Language , In software development , It is generally used for object-oriented analysis and design modeling .
in other words , We will develop a system using object-oriented language , To do the analysis and design of the system , It needs to be used UML Conduct analysis and design modeling .
object-oriented 、 Facial process

Multiple inheritance constructor call relationship
class A;
class B: virtual public A;
class C: virtual public A;
class E;
class D:public B, public C
among E yes D The children of
B and C Are all virtual inheritances from A,New One D Object time , First call A Constructor for , then D Sequential invocation of inherited classes B-->C Constructor for ;
Then call the sub object constructor , Because constructing sub objects E It's construction D Part of the mission , The last is D In itself

How to ensure Api The security of
Token Authorized certification , Prevent unauthorized users from accessing data , And Token Is the only one. , Overdue re acquisition, etc ;
Timestamp timeout mechanism ;
URL Signature , Prevent request parameters from being tampered with ;
Anti replay , Prevent the interface from being requested a second time , Anti collection ;
use HTTPS Communication protocol , Prevent data plaintext transmission ;
stand-alone 、 colony 、 Distributed 、 Microservices
Stand alone structure , That is, when the system business volume is very small, all the code is placed in one project , The project is deployed on a server . All services of the whole project are provided by this server . The disadvantage of single machine structure is the limited processing capacity , When the business grows to a certain extent , The hardware resources of a single machine will not meet the business requirements . At this point, the cluster mode appears
Cluster pattern , When the stand-alone processing reaches the bottleneck , You just make a few copies of the single machine , This constitutes a “ colony ”. Each server in the cluster is called one of the cluster “ node ”, All nodes form a cluster . Each node provides the same service , In this way, the processing power of the system can be increased several times .
But the question is which node will handle the user's request ? It is better to be able to let the node with smaller load handle at this moment , This makes the pressure at each node average . To implement this function , You need to add one... Before all the nodes “ Dispatcher ” Role , All requests from the user are given to it first , Then it depends on the current load of all nodes , Decide which node will handle the request . This “ Dispatcher ” Namely —— Load balancing server .
The advantage of cluster structure is that system expansion is very easy . If with the development of your system business , The current system can't support , Then add more nodes to the cluster . however , When your business develops to a certain extent , You will find a problem —— No matter how you add nodes , It seems that the performance improvement effect of the whole cluster is not obvious . Now , You need to use the microservice structure .
Distributed structure , Is to put a complete system , According to the business function , Split into independent subsystems , In a distributed architecture , Each subsystem is called “ service ”. These subsystems can be developed independently , Independent operation , Independent deployment .
- The coupling between systems is greatly reduced , The boundary between the system and the system is very clear , It's also quite easy to make mistakes , Development efficiency is greatly improved .
- The system is easier to expand . Some services can be extended pertinently .
- Services are more reusable . such as , When we use the user system as a separate service , All products of the company can use the system as a user system , No need for redevelopment .
Microservices are similar in nature to distributed services , Microservices can be placed in Docker Unified management in containers .
Redis cache
Redis The role of caching is to reduce the pressure on database access , When we access a data , Let's start with redis Check if there is this data in the , without , Read from the database , Store the data read from the database in the cache , The next time you access the same data is , Or judge first redis Whether the data exists in , If there is , Read from the cache , No more database access , Reduce the pressure on the database .
Server performance 、 load
The load can directly reflect the current state of the server .load average Represents the average of the machine over a period of time load, The lower the value, the better , Too much load will make the machine unable to handle other requests and operations , Even cause crash . The first consideration is to use servers with better performance . Secondly, we need to consider .
1、 Is there a memory leak that causes frequent GC
2、 Is there a deadlock
3、 Whether there are large field reading and writing
4、 Can it be caused by database operations , screening SQL Statement problem .
C# Memory related
c# Bring your own garbage collection mechanism , When there is not enough memory or the program ends GC Automatically reclaims objects on the managed heap . Of course, we can see from the name that this is for managed resources , For unmanaged resources , You can go through
1. Destructor : Call the object's Finalize Method to destroy the object .
2. Inherit IDisposable Interface , Realization Dispose() Method .
3. For database connection, you can use Using, Automatically called finally Method to release resources .
4. You can use singleton mode , Avoid creating objects repeatedly .
The singleton pattern : A private constructor , One getInstance Method .
Managed resources : Most reference types .
Unmanaged Resources : File stream , Database connection , Printer resources, etc .
Value type Value exists in the stack .
The reference type value exists on the heap , What exists in the stack is the heap address .
When declaring a class , First allocate a space on the stack and wait for the address in the storage heap ,new An object before allocating space in the heap , And assign the address to the stack .
1. Table connected SQL sentence , For internal connections inner join Come on ,join Statement and write the condition in where The result in the statement is the same , But for the left connection and the right connection, it is different , For example, left connection ,on The following conditions are only valid for the right table , The filter of the left table should be written in where Inside . and join on First, Cartesian product of two tables to form a table , Reuse where Condition screening , about join For many watches , From left to right , The smaller the table on the left, the more efficient it is . So try to write the conditions in on It can improve efficiency .
2. use Dapper frame When , Try not to use the form of concatenated strings SQL, Because someone has been attacked or SQL The risk of Injection , As far as possible with StringBulder.
Dapper.Query() Return query results The parameter is generally SQL sentence , Parameter variable , Business ,SQL type (SQL Statement or stored procedure )
Dapper.Execute() Returns the number of affected rows
GET Request and POST request
1.GET and POST yes http Two request modes of the protocol ,GET Generally used to request data ,POST It is generally used to pass parameters for updating, etc .
2.GET The request will bring the parameters to URL, Visible to users , and POST Is to put parameters into the request body , but GET You can also put parameters in the request body , But the server may not receive
3.POST Requests are relative to GET Ask for more security . because GET The parameters passed by the request will be displayed in url in , The browser will cache web pages when users visit , In this way, others will get private information when viewing the browser browsing records ,POST The request will not be seen by the user , So it's safe .
4.GET Request in URL There is a length limit on the parameters passed in , and POST It has a .
5. The data type for the parameter ,GET We only accept ASCII character , and POST There is no limit to .
6. about GET Method request , The browser will http header and data Send along , Server response 200( Return the data );
And for POST, Browser sends first header, Server response 100 continue, The browser sends data, Server response 200 ok( Return the data ). But not all browsers will be in POST Send two packets in ,Firefox Just send it once .
EntityFrameWork and .NET Core contrast
Can't say Core Certain ratio EF good , however Core One of the biggest advantages is cross platform , Open source , And more IDE Support Core(VS ,VS CODE), and EF Relatively more stable ,EF It is also more widely used , in addition WCF Services and forms do not support Core
But when the customer has the following requirements, we should consider Core
- Users have cross platform requirements .
- Users are facing microservices (Azure).
- The user is using Docker Containers .
- Need high performance and scalable systems .
- Need to provide parallel... By application .NET edition ( Different versions .net core( May be 2.0 and 3.0), image EF It could be 4.0 perhaps 4.1).
3.String and StringBuilder
string Itself is unchangeable , It can only be assigned once , Every time the content changes , Will generate a new object , Then the original object references the new object , Every time a new object is generated, the system performance will be affected , This will reduce .NET The efficiency of the compiler

and StringBuilder Class is different , Each operation is an operation on its own object , Instead of generating new objects , The space it takes up will expand as the content increases

When the program needs a lot of operation on a string , Applications should be considered StringBuilder Class handles the string , It is designed for a large number of string An improved method of operation , Avoid generating too many temporary objects ; When the program only performs one or more operations on a string , use string The class can .
4.ASP.NET and .NET The difference between :
.Net It's the platform , The following includes many languages , such as C#,VB,C++ etc. , and .NET There are mainly two parts ,WinForm(CS) and WebForm(BS), and ASP.NET Belong to .NET The next part , It's mainly used to do WebForm project . Compile to form CLR( Interlingua ), And then through the server IIS+.Net FrameWork Compile again to run .
5. entrust
Reference type , use delegate To declare , The parameters and return types are the same as the corresponding methods
Make it possible to pass a method as an argument to another method , This method is dynamically assigned to parameters , Avoid extensive use in programs If-Else(Switch) sentence , At the same time, the program has better scalability .
The system itself has two well-defined delegate types , among Action No return value (void) Type method ,Func There is a return value
6. Boxing and UnBoxing
Boxing is to implicitly convert a value type to a reference type object .
Unpacking is to convert a reference object into an arbitrary value type .
such as :
int i=0;
Syste.Object obj=i;
The process is packing ! Will be i Packing !
such as :
int i=0;
System.Object obj=i;
int j=(int)obj;
Before this process 2 Sentence is will i Packing , The last sentence is to obj Unpacking !
7.BS and CS Advantages and disadvantages of Architecture
B/S Browser side / Server side : Low development cost , The version is always the latest , Wide range of application , The ability to control security is relatively weak , Facing the unknown user group .
C/S client / Server side : Low communication cost , The client needs to be installed , Manual upgrade
8.DataReader and DataSet
The biggest difference between the two is ,DataReader Always occupy when using SqlConnection, Operate the database online . Any right SqlConnection The operation of will cause DataReader It's abnormal . because DataReader Load only one piece of data in memory at a time , So the memory used is very small .. because DataReader The particularity and high performance of . therefore DataReader It's the only way in . You can't read the first one after you read the first one .
DataSet For offline operation data ,DataSet Will read data into memory at one time , Then disconnect , At this time, other operations can use SqlConnection Connection object . because DataSet Load all data into memory . So it consumes more memory . But it's better than DataReader Be flexible . You can dynamically add rows , Column , data . Update the database
9. stay c# in using and new What's the meaning of these two keywords ?using Instructions and statements new Create examples new Hide methods in base class .
using Introduce namespaces or use unmanaged resources , amount to try catch finally Automatically execute the implementation after using the object IDisposable Class of interface Dispose Method to release object resources
new Create a new instance or decorate a method , Indicates that this method completely overrides ( That is, hide the base class methods )
10. Virtual functions / Abstract functions / Interface / Static functions
① Virtual functions : There is an implementation , Achieve polymorphism , Subclasses can be overridden or used without overriding . use Virtual modification , Can only be inherited by a single
② Abstract functions : Is a class , There are constructors , use abstract modification , There is no implementation , Non virtual subclasses must override , An abstract method must be an abstract class , But abstract classes don't necessarily have abstract methods . Can only be inherited by a single
③ Interface : Not class , There is no constructor , Support polymorphism , use Interface modification , There is no implementation , Subclasses must override , Support for multiple inheritance
④ Static functions : use static modification , It is initialized when used for the first time , For all objects of this class ,static Only one member variable ,static Inaccessible non in method static Members of .
Put keywords in front of class definitions sealed, You can declare a class as a sealed class . When a class is declared sealed when , It cannot be inherited . An abstract class cannot be declared sealed.
11. Overloading and rewriting
heavy load : The same method name , Different parameters , Or the number of parameters is different , Is a manifestation of too much , Or different return values , Or the modifier is different
rewrite : Inherited parent class , Override the method of the parent class
override( rewrite )
1、 Method name 、 Parameters 、 Same return value .
2、 A subclass method cannot reduce the access rights of a parent method .
3、 A subclass method cannot throw more exceptions than a parent method ( But subclass methods can not throw exceptions ).
4、 It exists between the parent class and the child class .
5、 Method is defined as final Can't be rewritten .
overload( heavy load )
1、 Parameter type 、 Number 、 There is at least one different order .
2、 Can't overload method names that only return different values .
3、 It exists in the parent class and the child class 、 Of the same kind .
12. Classes and structures have the following basic differences :
Class is a reference type , A structure is a value type .
Structure does not support inheritance .
Structure cannot declare a default constructor .
Class is stored in heap space , Structures are stored on the stack . Large heap space , But access is slow , Stack space is little , Access speed is relatively faster
13. Value type and reference type
Value type ( Such as char、int and float)、 Enumeration and structure .
Reference types include classes (Class) 、String、 Interface 、 Delegates and arrays .
Declare a value type variable , The compiler allocates a space on the stack to store the value of the variable .
Instances of reference types are allocated on the heap , Store... In the stack Heaped Memory allocation Address
When declaring a class , First allocate a space on the stack and wait for the address in the storage heap ,new An object before allocating space in the heap , And assign the address to the stack .
14. Reflection (Reflection)
advantage :
1、 Reflection improves the flexibility and extensibility of programs .
2、 Reduce coupling , Improve self adaptability .
3、 It allows programs to create and control objects of any class , No need to hard code the target class in advance .
shortcoming :
1、 Performance issues : Using reflection is basically an interpretation operation , It's much slower for field and method access than for direct code . Therefore, the reflection mechanism is mainly used in the system framework which requires high flexibility and expansibility , It is not recommended to use .
2、 Using reflection can blur the internal logic of the program ; Programmers want to see the logic of the program in the source code , Reflection bypasses the source code technology , This will bring about maintenance problems , Reflection code is more complex than the corresponding direct code .
Reflection (Reflection) It has the following uses :
It allows you to view features at run time (attribute) Information .
It allows you to review various types of , And instantiating these types .
It allows delayed binding of methods and properties (property).
It allows you to create new types at run time , Then use these types to perform some tasks .
C# Advanced tutorials https://www.runoob.com/csharp/csharp-attribute.html
15. Generic
When we write a method with parameters , Parameter types generally need to be specified ,Public void Test(int a)
But it is similar to reloading , When different parameter types are passed , We may Public void Test(string b),Public void Test(datetime c), But if there are many types , This method is obviously not suitable .
Or we can Public void Test(Object a) It looks like once and for all , But in fact, this process requires a lot of boxing and unpacking operations , If the number of visits is very large, it will consume performance . At this point, you can use generics Public void Stack<T>
CompareModels<in T>(T originalModel, T updatedModel)
16. Anonymous functions and anonymous methods :
Anonymous functions do not need to specify a return type , It's from within the method body return The sentence infers .
Anonymous methods are methods that have no names but only principals .
The anonymous method is by using delegate Keyword to create a delegate instance to declare
delegate void NumberChanger(int n);
...
NumberChanger nc = delegate(int x)
{
Console.WriteLine("Anonymous Method: {0}", x);
};
https://www.runoob.com/csharp/csharp-anonymous-methods.html
17. Multithreading and thread locking :
https://blog.csdn.net/afei__/article/details/80468265
Threads are lightweight processes
The thread life cycle starts at System.Threading.Thread When an object of class is created , End when the thread is terminated or finished executing
Not started : When a thread instance is created but Start State when method is not called .
Ready state : When the thread is ready to run and wait CPU The condition of a cycle .
Non operational state : Threads are not runnable in the following cases :
Has called Sleep Method
Has called Wait Method
adopt I/O Operation blocking
Death state : The condition when a thread has completed execution or has been aborted .
The first thread executed in a process is called the primary thread .
Locks and deadlocks
This is used in multithreading , Thread lock is used to control the utilization and release of resources for thread safety , For example, the most intuitive ticketing system , The same ticket can only be sold at one window , And the remaining tickets cannot be negative , Otherwise, the thread is not safe
To prevent this from happening Added thread lock , But it's not used properly , For example, a process occupies a resource , But then ask for new resources , But the new resources are occupied by other processes , He has not released current resources , In this way, the next process requesting the resource will cause congestion , That's deadlock , To prevent this from happening
Lock sequence ( Threads lock in a certain order )
Lock time limit ( A certain time limit is added when the thread attempts to acquire the lock , If the time limit is exceeded, the request for the lock will be abandoned , And release the lock you own )
Deadlock detection
18.IEnumberable and IQueryable and Tolist()
IEnumberable Interfaces become iterators , Just one GetEnumberator() Method ; It returns a IEnumberator Object this is an object that can iterate through a collection ,IEnumberator Is a collection accessor . Support foreach sentence ,IEnumberator Defined Current attribute ,MoveNext and Reset Two methods ;Current Used to get items in the collection ,MoveNext Method simply moves the cursor's internal position forward ( Is to move to the next element )
IQueryable Inherit IEnumberable Interface , Both are deferred execution
IEnumerable<T> Generic classes are calling their own SKip and Take Before the extension method, the data has been loaded into the local memory , In actual use, subsequent methods will be executed in memory to obtain results , Compare memory consumption , And will always be connected to the database
and IQueryable<T> Yes, it will Skip ,take These method expressions are translated into T-SQL Statement and then to SQL The server sends commands , It does not load all data into memory to perform conditional filtering . But still connected to the database
Tolist() Will be executed immediately , Load the results into memory , And disconnected from the database .
19.viewbag and viewdata
ViewData and ViewBag Commonly used in View and Controller Indirect transmission value ,
ViewData yes key Value reads the corresponding value,ViewData["Name"] = " long-horned grasshopper ";
ViewBag Is a dynamic type , When using, you can directly assign values through attributes ,ViewBag.Message = "Your application description page.";
ViewData and ViewBag Only in the present Action Effective in , Equate to View
ViewData and ViewBag Values in can be accessed from each other
20. Message queue
A message queue is compared to a container for storing messages , When we need to use messages, we can retrieve them for our own use .
Message queuing is an important component of distributed system , Message queuing is mainly used to improve system performance and peak shaving through asynchronous processing 、 Reduce system coupling . At present, the message queues that are used more often are ActiveMQ,RabbitMQ,Kafka,RocketMQ
queue Queue It's a first in, first out data structure , So when you consume messages, you consume them in order
The most common use of message queuing is publishing - A subscription model , There's also a point-to-point subscription model ( A message has only one consumer )
After using message queuing for asynchronous processing , The business process needs to be modified properly to cooperate , For example, after the user submits the order , Write order data to message queue , Can't return user's order submission success immediately , After the order consumer process of the message queue actually processes the order , Even after leaving the warehouse , Then notify the user of the success of the order through email or SMS . The most common booking system .
Using message queuing requires attention
①. Ensure reliable transmission of messages ( How to deal with the problem of message loss ) https://blog.csdn.net/evilcry2012/article/details/87718450
②. How to ensure the order of messages ? https://blog.csdn.net/evilcry2012/article/details/86715842
20. Synchronous and asynchronous
Synchronous asynchronous It means on the client
Synchronization means After the client makes a request , Can only wait before responding
Example : You call the bookstore owner and ask if he has 《 Distributed systems 》 This book , If it's a synchronous communication mechanism , The bookstore owner will say , Just a moment ,” Let me check ", And then I started to check , Wait until we find out ( May be 5 second , It could be a day ) Tell you the result ( Return results ).
Asynchrony means After the client makes a request , You can continue to make other requests
Example : The bookstore owner will tell you that I will check it , Check it out and call you , And then just hung up ( No results returned ). Then I checked , He will call you on his own initiative . Here the boss passes “ Call back ” This way to callback .
Blocking non blocking It refers to the server side
Blocking means After the server accepts a request , Other requests cannot be accepted until the result is returned
Non blocking means After the server accepts a request , Although no results are returned , You can still continue to accept other requests
21. Constructors and destructors
Destructor : When the function of the object has been called , The system automatically performs the destructor . A particular class can have multiple constructors , They can be distinguished according to the number of parameters or the type of parameters That is, overloading the constructor .
Destructor : It's a special method . Used before undoing an object , Finish some cleaning work , such as : Free up memory, etc . But in general GC( The garbage collection mechanism helped us get rid of )
22.IIS and IIS Express
IIS It's a system service ,IIS Express Is just a temporary process .
IIS We need to install , You can manually deploy published applications , You can also run the program directly. The default setting is IIS Of Default Web Site in . There's a visual interface
IIS Express Integrated in the VS in , For debugging , No visual interface , There are configuration files .
23. enumeration
Enumeration is a set of named integer constants . The enumeration type is using enum Keyword declared .
An enumeration is a value type . The enumeration type is saved in the database Position in enumeration
Enum.GetName(typeof( The financing party is ), type); Get the original value
24.DataTable and DataSet
DataSet As a database in memory ,DataSet It's a separate data set that doesn't depend on a database . Independence , That is to say , Even if it's disconnected The data link , Or shut down the database ,DataSet Still available ,DataSet Internally, it is used XML To describe the data ,DataSet There may be more than one DataTable
DataTable Is a grid virtual table that temporarily saves data ( A table representing data in memory )
25. Skip( skip ) Take( obtain ) (C# Extension method of inner set , Often used as paging )
var list = new List<int>();
// such as list Inside is 1,2,3,4,5,6,7,8,9,10
var result = list.Skip(2); // The return value is 3,4,5,6,7,8,9,10;
var result = list.Take(2); // The return value is 1,2
// Use it with , Generally used for paging
var result = list.Skip(2).Take(2); // Return value 3,4
26. Compare the array (Array)/ aggregate (Set)/ list (List)
1、 The storage content is relatively : Array Arrays can contain basic types and object types , ArrayList It can only contain object types . Array Arrays must be elements of the same type when stored .ArrayList Not necessarily . aggregate Set The objects of are not repeated , And it's out of order .
2、 The space size is relatively large : Array The space size of the array is fixed , Therefore, it is necessary to determine the appropriate space size in advance . ArrayList The space is growing dynamically , and , Each time a new element is added, it is checked whether the space of the internal array is enough .
3. Methodological comparison : ArrayList The method is better than Array More variety , For example, add all addAll()、 Delete all removeAll()、 Return iterator iterator() etc. .
边栏推荐
- 基于ESP32CAM实现WebSocket服务器实时点灯
- Is it safe to open an account online in Hangzhou?
- 【微弱瞬态信号检测】混沌背景下微弱瞬态信号的SVM检测方法的matlab仿真
- Nfv basic overview
- Reflection of C # Foundation
- How to quickly support the team leader to attract new fission users in the business marketing mode of group rebate?
- That is, after the negative impact of gcat advertising e-commerce, is there no stable advertising e-commerce platform?
- Network planning common interview knowledge (I)
- 数字时代进化论
- Jinglianwen technology provides a one-stop smart home data acquisition and labeling solution
猜你喜欢

YOLOv5解析 | 参数与性能指标

Jinglianwen Technology: current situation and solutions of data acquisition and labeling industry

髋关节MR详细图谱(转载)

Tidb statistics

16、 IO stream (II)

Tidb data migration (DM) Introduction

上位机开发(固件下载软件之详细设计)

Host computer development (Architecture Design of firmware download software)

RT thread simulator lvgl control: switch switch button control

The biggest highlight of wwdc2022: metalfx
随机推荐
Introduction and use of dumping
检测循环数“142857“
Project analysis of Taishan crowdfunding mode: why is Taishan crowdfunding mode so popular?
c#高級編程-特性篇
Tidb server tuning
Upper computer development (software test of firmware download software)
How to make a development board from scratch? Illustrated and illustrated, step by step operation for you to see.
June 12, 2022: if there are n*n pieces in an n*n square chessboard, each grid can have exactly one piece. But now some pieces are gathered on a grid, such as 2030100300. The above two-dimensional arra
C # using multithreading
RT thread simulator lvgl control: button button style
Jinglianwen technology provides a one-stop smart home data acquisition and labeling solution
First day of learning MySQL Basics
怎么写出一份令人惊叹的设计文档?
汇编语言基础:寄存器和寻址方式
在 localStorage 中上传和检索存储图像
Jinglianwen Technology: current situation and solutions of data acquisition and labeling industry
Priority analysis of list variables in ansible playbook and how to separate and summarize list variables
【马尔科夫链-蒙特卡罗】马尔科夫链-蒙特卡罗方法对先验分布进行抽样
【腾讯阿里最全面试题集锦】(四面:3轮技术+1轮HR)
树莓派高级开发——“IO口驱动代码的编写“ 包含总线地址、物理_虚拟地址、BCM2835芯片手册知识