Meshfilter determines what shape the object is.
Meshrender determines the appearance of the object;
Operating constant: readonly
1.readonly string name_readonly = "ReadOnly string";
2.//correct, can define any data type
ReadOnly Program program_readonly = new program ();
3. Structure: Inherit from System,object not allowed to inherit
such as Struct point
{
public int x;
public int y;
public point (int x, int y)
{
this.x = x;
This.y = y;
}
}
4. Enumeration type:
All enum types inherit from the System.Enum type by default, and System.Enum inherit from System.ValueType. Therefore, the enumeration is a struct type.
The
//:long table encloses the underlying type is long
//If not written, the default is int
enum Alignment:long
{
//= is also not writable, by default it starts with 0, plus 1
left =-1,
Center = 0,
right = 1
}
public class Test
{
static void Main ()
{
Initializing an enumeration variable
Alignment Alignment = Alignment.left;
Output: Left
Console.WriteLine (alignment);
Output: 1
Console.WriteLine ((long) alignment);
Get the underlying type
Type Underlyingtype = Enum.getunderlyingtype (typeof (Alignment));
Output: System.Int64
Explanation: [Long keyword mapping is of type System.Int64]
Console.WriteLine (Underlyingtype.fullname);
}
}
5. Arrays
public class Test
{
static void Main ()
{
An array of type int with an element number of 3
Int[] ages = new Int[3];
Multidimensional array of 3 X 3
int[,] i = new int[3, 3];
Jagged arrays
Int[][] J = new int[2][];
J[0] = new Int[2] {3, 4};
J[1] = new INT[3];
Output: 4
Console.WriteLine (J[0][1]);
}
}
6. String:
A large part of the writing process is the time to deal with strings. given by Microsoft. NET class Library also gives some types of string processing.
Common string processing classes in C #:
System.String
System.Text.StringBuilder
String classes can be used to create, intercept, replace, merge, and so on. You can also use "+" to facilitate the merging of strings.
The uppercase string is exactly the same as the lowercase string, and uppercase refers to it. NET class library, lowercase is the C # keyword and corresponds to the type of string. In C #, for example, int and Int32 also correspond.
The special point of string:
invariance;
Read share, write copy;
string dwell technology;
A string is a reference type, but its value is immutable, that is, the assigned value cannot be changed. Some operations on strings, such as merging, intercepting, result in a new string object.
Because of the nature of write replication, in some cases where a large number of strings are merged, a lot of temporary string objects are generated, and then discarded, wasting a lot of memory. So there is another System.Text.StringBuilder type in the class library to efficiently stitch strings.
public class Test
{
static void Main ()
{
String name = "[Xiaoming";
Merging strings
Name = name + "20 years old";
Name = name + "Boy");
Console.WriteLine (name);//[Xiao Ming, 20 years old boy]
Replace space with "-"
Name = name. Replace (', '-');
Console.WriteLine (name);//[-Xiaoming-20 years old-boys------]
}
}
public class Test
{
static void Main ()
{
System.Text.StringBuilder StringBuilder =
New System.Text.StringBuilder ();
for (int i = 0; i <; i++)
{
Append string
Stringbuilder.append (i.tostring () + "|");
}
Output: 1|2|3|4|5.....999|
Console.WriteLine (Stringbuilder.tostring ());
}
}
7. Commission:
A
A delegate type (delegate type) represents a reference to a method with a specific argument list and return type. By delegating, we can assign a method as an entity to a variable and pass it as a parameter. Delegates are similar to the concept of function pointers in some other languages, but unlike function pointers, delegates are object-oriented and type-safe.
A delegate declaration defines a class that derives from the System.Delegate class. A delegate instance encapsulates a list of calls that list one or more methods, each called a callable entity. For an instance method, the callable entity consists of the method and an associated instance. For static methods, the callable entity consists of only one method. Invoking a delegate instance with an appropriate set of parameters is the invocation of each callable entity of the delegate instance using the given set of parameters.
B, Delegate properties
Passing a method as a parameter
Typically, a variable (field) is passed, and a delegate is a delivery method
callback method
The underlying code defines the type (delegate) of the method signature, which defines the delegate member
Upper layer Code creation method, create delegate instance, let the method that need to call pass to the bottom
The bottom layer calls the upper method by invoking the delegate
Multi-channel broadcast
Can maintain references to multiple methods at the same time (+ =,-=)
Delegates are type-safe
Delegatea Da;delegateb db; Da=db is not executed even if the function signature is the same;
The delegate types are sealed (sealed)
Cannot inherit
C, an important member of the Commission
Target
A property of type object that points to the instance of the object to which the callback function belongs (for instance methods)
Target is null when the referenced method is a static method
Method
Properties of the System.Reflection.MethodInfo type, pointing to the callback function
Invoke
Functions, executing delegates synchronously
BeginInvoke
Begins an asynchronous execution of a delegate
EndInvoke
Complete asynchronous execution
Review1 (C # language Foundation)