Professional Documents
Culture Documents
-----> <!-------------------><!--
-----> <!--------------------><!--
#
-
(Pointers)
C#
.Net
C#
(Compile).
.
: -
(Pointers)
(Pointers)
: -
C (Pointers)
C++
(Dynamic Array)
(Jagged Arrays)
(Late or Dynamic Binding) (Strings Array)
. (Pointers)
(Dynamically)
C
C++
(Java)
(GC) (Garbage Collector)
.
.
(Pointers)
C
C++
C#
-
// NormalCopy.cs
using System;
public class NormalCopy
{
public static void CopyArray(byte [] Src, byte [] Dst)
{
for (int j = 0; j < 10000; ++j)
for (int i = 0; i < Src.Length; ++i)
Dst = Src;
}
CopyArray(MySrcArray, MyDstArray);
Console.Read();
}
}
:
(Array)
(byte)
(Loop)
.
(Pointers)
C#
(Java) - GC -
(Pointers)
(Pointers) - -
C
C++
.
(Pointers) -
C#
C#
(Pointers)
C#
(DLL)
(COM)
.Net
(Pointers)
C#
C
C++
(Java)
(Classes) (Libraries)
(Infrastructure)
.Net
(Pointers).
(Pointers)
C#
(Reserved word (unsafe)
(Code) or Keyword)
(Pointers)
(Functions) (Properties) (Members)
(Classes) (Constructors)
:
// Using 'unsafe' as block in a functionvoid MyFunction()
{
...
unsafe
{
// Unsafe code to be here
}
...
}
// Using 'unsafe' in function declarationunsafe void MyFunction()
{
// Do something
}
// Using 'unsafe' in class declarationunsafe class MyClass
{
// Class body to be here
}
(unsafe)
.Net
.Net
(Pointers)
(unsafe)
.Net
.
(Intermediate (unsafe) (Code)
(Source (IL) Language)
(dll) (exe) (Assembly) - Code)
(unsafe) (unsafe) (Assembly)
.Net
(Assembly).
C#
(Compile
C#
( (unsafe) Code)
/unsafe
)
C#
(
C#
: Compiler)
csc /unsafe MyFile.cs
(csc)
C#
(
C#
(MyFile.cs) Compiler) -
(IL) (Compile)
(Pointers): -
(Pointer Types)
C#
C
C++
(Data Type)
(Pointer)
(Pointers)
C#
(Objects) (Type Safe)
C#
(Pointer to Object)
C++
:
MyClass MyObject = new MyClass(); // in
C#
MyClass * MyObject = new MyClass(); // in
C++
C#
:
void *
. (Pointer) :
type *
: (type)
: (Value Types)
bool, sbyte, byte, short, ushort, int, uint, long, ulong, char,
float, double, decimal, enum
(Pointer Types):
(Pointer to Pointer)
(User-Define Types):
(Classes) (Structures)
(Value Types)
(Reference Types) (Pointing to)
(Structures)
. (Reference Types)
:
byte * pMyByte; // Pointer to byte bool * pMyBool; // Pointer to
boolint * * pMyInt; // Pointer to pointer to intlong * [] pMyLong; //
Array of pointers to longvoid * pMyVoid; // Pointer to unknown
typechar * pC1, pC2; // Two Pointers to char
// string * pMyString; // Error, 'string' is reference type
// The compiler generates the following error message:
// Indirection to managed type is not validbyte MyByte = 10; // byte
variable
pMyByte = & MyByte; // pMyByte now points to MyByte (i.e. The
value // of pMyByte is the address of MyByte)// Array of boolbool []
MyBool = {true, false, false, true};// pMyBool = MyBool // Error,
arrays is also reference types
// The compiler generates the following error message:
// Cannot implicitly convert type 'bool[]' to 'bool*'// To point to an
array use 'fixed' statementfixed (bool * pB = MyBool)
{
for (int i = 0; i < MyBool.Length; ++i)
Console.WriteLine((pB + i)->ToString());
C#
-
(
T*
(T) )
(Pointer Types) (Object)
(Operator) (
->
(Operator) (.) )
:(
pMyByte->ToString()
)
(Reference Types) (Arrays)
(GC)
-
(Pointing to
(Object) - (fixed) Arrays)
(fixed) (GC)
(Object) (GC)
(Object)
(Pointer)
. (fixed)
: -
(Pointers)
(NormalCopy.cs)
(Array)
MSDN):
// FastCopy.csusing System;
public class FastCopy
{
public static unsafe void CopyArray(byte [] Src, byte [] Dst)
{
fixed (byte * pSrc = Src, pDst = Dst)
{
byte * pS = pSrc;
byte * pD = pDst;
int Count = Src.Length;
CopyArray(MySrcArray, MyDstArray);
Console.Read();
}
}
( (Pointer)
int *
)
( (Loop)
>>
(Right-Shift Operator) )
(Operand) (Operand)
(Count >> 2)
(Loop)
(Bitwise AND) (&
(Operand)
(Count &= 3) (Operand)
(Loop)
(Loop)
(Loop) (Array)
.
(Pointers)
.
MSDN (Pointers)
(Pointers)
(Pointers).
: -
(Pointers)
C#
C
C++
(Pointers)
C#
C# - <!-------------------->
------> C#<!--
public :
private :
Object :
Comment :
Address :
Casting :
Implicit Casting :
Explicit Casting :
Overloading :
Operand :
Instance :
Procedure :
Container :
Parameter :
Argument :
Array :
Operator :
initialization :
encapsulation :
Polymorphism :
inheritance :
Class :
Base class :
Derived class :
Derivation :
Constructor :
, Destructor :
Method :
Property :
Keyword :
Virtual :
Pointer :
Void Pointer :
Visibility :
Accessibility :
Variable :
Constant :
protected :
Integer :
Float, Double Number :
Reference :
Loop :
Template :
Prototype :
Function Signature :
Default Argument :
Default Case :
Email:-nabil299@gmail.com