C# Environment StackTrace

Description

Environment StackTrace gets current stack trace information.

Syntax

Environment.StackTrace has the following syntax.


public static string StackTrace { get; }

Parameters

Environment.StackTrace has the following parameters.

  • - The full name of the class, including the namespace.
  • - The name of the method.
  • - The list of parameter type/name pairs. Each pair is separated by a comma (","). This information is omitted if MethodName takes no parameters.
  • - The name of the source file where the MethodName method is declared. This information is omitted if debug symbols are not available.
  • - The number of the line in FileName that contains the source code from MethodName for the instruction that is on the call stack. This information is omitted if debug symbols are not available.

Example

The following example demonstrates the StackTrace property.


//from  ww w  .ja va 2 s.c om

using System;

class Sample 
{
    public static void Main() 
    {
       Console.WriteLine("StackTrace: '{0}'", Environment.StackTrace);
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version