Class Library:
is to have someone call your way of writing and not let others see how you do it. (e.g. some core files)
If there is a function you do not do and need help from others, then your colleague can help you write a class and then you call the method in this class to complete your project.
Add a class to the other project and write the function well. Then locate the source file copy, paste the class in the project you want to add, and then reference (using XXX;). After instantiation, you can reference it.
1. C # source code files, including in their own projects
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Using System.Threading.Tasks;
Using the referenced file;//namespace of the project that provides the add and subtract method
Using class Library;//class library file namespace that provides the multiplication method
namespace referencing others _ files
{
Class Program
{
static void Main (string[] args)
{
int a = 10;
int B = 20;
Add and Subtract class J = new Plus minus class ();//Another project adds a class name and then instantiates
int c = J.jia (A, B);//Using the Jia function
int d = new Chengchu (). Cheng (A, B);//instantiation, using the multiplication method
Console.WriteLine (c);
Console.WriteLine (d);
Console.readkey ();
}
}
}
2. Class library,. dll
Advantages: You write a method that others do not see the implementation process, strong confidentiality
Cons: If you write a method with errors, others cannot change
Create a new class library, add a class, write the method in the class, locate the file in File Explorer (. dll format), and then copy the file to the file that you want to reference the method in, and then add the. dll in the referenced project by using "References" in the Solution Explorer, and then using XXX.
Commissioned
Namespace delegate
{
Class Program
{
declaring delegate types
public delegate int Firstdel (int aa, int bb);
static void Main (string[] args)
{
int a = 10;
int B = 20;
Firstdel f1 = new Chengchu (). cheng;//defines a F1 delegate variable, which points the multiplication method to the F1 variable.
int c = F1 (A, b);
New program (). AAA (F1, 10);//Call the AAA method and call multiply
Console.WriteLine (c);
Console.readkey ();
}
public void AAA (Firstdel F, int a)//a method with no return value
{ }
}
}
var: universal type
Object: base class for all types
As: type conversion, if the conversion is unsuccessful, does not error, but returns a null
is: Determines whether a variable/object is a certain type, returns a bool value
Generic collection: List<t>
A set of fixed-length, invariant types
Class Library, delegate, As.is,var, generic collection