खोज…


Debug.WriteLine

डिबग कॉन्फ़िगरेशन में अनुप्रयोग संकलित होने पर श्रोताओं के संग्रह में ट्रेस श्रोताओं को लिखता है।

public static void Main(string[] args)
{
    Debug.WriteLine("Hello");
}

Visual Studio या Xamarin स्टूडियो में यह एप्लिकेशन आउटपुट विंडो में दिखाई देगा। यह TraceListenerCollection में डिफ़ॉल्ट ट्रेस श्रोता की उपस्थिति के कारण है।

TraceListeners के साथ लॉग आउटपुट को पुनर्निर्देशित करना

आप डिबग के लिए एक पाठ फ़ाइल में डिबग उत्पादन को पुनर्निर्देशित कर सकते हैं।

public static void Main(string[] args)
{
    TextWriterTraceListener myWriter = new TextWriterTraceListener(@"debug.txt");
    Debug.Listeners.Add(myWriter);
    Debug.WriteLine("Hello");

    myWriter.Flush();
}

आप कंसोल कंसोल के उपयोग से कंसोल एप्लिकेशन के आउट स्ट्रीम में डीबग आउटपुट को पुनर्निर्देशित कर सकते हैं।

public static void Main(string[] args)
{
    ConsoleTraceListener myWriter = new ConsoleTraceListener();
    Debug.Listeners.Add(myWriter);
    Debug.WriteLine("Hello");
}


Modified text is an extract of the original Stack Overflow Documentation
के तहत लाइसेंस प्राप्त है CC BY-SA 3.0
से संबद्ध नहीं है Stack Overflow