הערה
גישה לעמוד זה דורשת אישור. אתה יכול לנסות להיכנס או לשנות תיקיות.
גישה לעמוד זה דורשת אישור. אתה יכול לנסות לשנות מדריכים.
The using keyword has two major uses:
- The
usingstatement defines a scope at the end of which an object is disposed:
string filePath = "example.txt";
string textToWrite = "Hello, this is a test message!";
// Use the using statement to ensure the StreamWriter is properly disposed of
using (StreamWriter writer = new StreamWriter(filePath))
{
writer.WriteLine(textToWrite);
}
- The
usingdirective creates an alias for a namespace or imports types defined in other namespaces:
using System;
using System.IO;
See also
שתפו איתנו פעולה ב-GitHub
המקור לתוכן זה נמצא ב-GitHub, שם ניתן גם ליצור ולבחון בעיות ולמשוך בקשות. למידע נוסף, ראו את מדריך התורמים שלנו.