אירוע
בניית אפליקציות וסוכנים של בינה מלאכותית
17 במרץ, 21 - 21 במרץ, 10
הצטרף לסידרה של פגישות כדי לבנות פתרונות מדרגיים של בינה מלאכותית בהתבסס על מקרי שימוש מהעולם האמיתי עם מפתחים ומומחים אחרים.
הירשם עכשיוהדפדפן הזה אינו נתמך עוד.
שדרג ל- Microsoft Edge כדי לנצל את התכונות, עדכוני האבטחה והתמיכה הטכנית העדכניים ביותר.
The unsafe
keyword denotes an unsafe context, which is required for any operation involving pointers. For more information, see Unsafe Code and Pointers.
You can use the unsafe
modifier in the declaration of a type or a member. The entire textual extent of the type or member is therefore considered an unsafe context. For example, the following is a method declared with the unsafe
modifier:
unsafe static void FastCopy(byte[] src, byte[] dst, int count)
{
// Unsafe context: can use pointers here.
}
The scope of the unsafe context extends from the parameter list to the end of the method, so pointers can also be used in the parameter list:
unsafe static void FastCopy ( byte* ps, byte* pd, int count ) {...}
You can also use an unsafe block to enable the use of an unsafe code inside this block. For example:
unsafe
{
// Unsafe context: can use pointers here.
}
To compile unsafe code, you must specify the AllowUnsafeBlocks compiler option. Unsafe code is not verifiable by the common language runtime.
// compile with: -unsafe
class UnsafeTest
{
// Unsafe method: takes pointer to int.
unsafe static void SquarePtrParam(int* p)
{
*p *= *p;
}
unsafe static void Main()
{
int i = 5;
// Unsafe method: uses address-of operator (&).
SquarePtrParam(&i);
Console.WriteLine(i);
}
}
// Output: 25
For more information, see Unsafe code in the C# Language Specification. The language specification is the definitive source for C# syntax and usage.
משוב של .NET
.NET הוא פרויקט קוד פתוח. בחר קישור כדי לספק משוב:
אירוע
בניית אפליקציות וסוכנים של בינה מלאכותית
17 במרץ, 21 - 21 במרץ, 10
הצטרף לסידרה של פגישות כדי לבנות פתרונות מדרגיים של בינה מלאכותית בהתבסס על מקרי שימוש מהעולם האמיתי עם מפתחים ומומחים אחרים.
הירשם עכשיו