C# Program to Get Current Stack Trace Information Using Environment Class Last Updated : 21 Nov, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report In C#, Environment Class provides information about the current platform and manipulates, the current platform. It is useful for getting and setting various operating system-related information. We can use it in such a way that it retrieves command-line arguments information, exit codes information, environment variable settings information, contents of the call stack information, and time since the last system boot in milliseconds information. By just using some predefined methods we can get the information of the Operating System using the Environment class. Here in this article, we are using the StackTrace property to get the current stack trace information. This property is used to get the current stack trace information Syntax: string Environment.StackTrace Return: string and gives the class name along with id Example 1: C# // C# program to find the current stack trace information using System; class GFG{ static public void Main() { // Define the variable with string string my_variable = "Hello Geeks"; // Get the current stack trace details // Using StackTrace property my_variable = Environment.StackTrace; Console.WriteLine("Information of current stack trace: \n" + my_variable); } } Output: Current Stack Trace Details: at System.Environment.get_StackTrace () [0x00000] in <a1ae6166591d4020b810288d19af38d4>:0 at GFG.Main () [0x00000] in <ec0c23afce674aedba9f00d218402cf6>:0 Example 2: C# // C# program to find the current stack trace information using System; class GFG{ static public void Main() { // Define the variable with integer string my_variable = "58"; // Get the current stack trace details // Using StackTrace property my_variable = Environment.StackTrace; Console.WriteLine("Information of current stack trace: \n" + my_variable); } } Output: Current Stack Trace Details: at System.Environment.get_StackTrace () [0x00000] in <a1ae6166591d4020b810288d19af38d4>:0 at GFG.Main () [0x00000] in <092e5ea1577d4af6be34040e9472afab>:0 Comment More infoAdvertise with us Next Article C# Program to Get Number of Processors of Current Machine using Environment Class O ojaswilavu8128 Follow Improve Article Tags : C# CSharp-programs Similar Reads C# Program to Get the Path of System Directory Using Environment Class In C#, Environment Class provides information about the current platform and manipulates, the current platform. It is useful for getting and setting various operating system-related information. We can use it in such a way that it retrieves command-line arguments information, exit codes information, 2 min read C# Program to Get the Operating System Version of Computer using Environment Class In C#, Environment Class provides information about the current platform and manipulates, the current platform. It is useful for getting and setting various operating system-related information. We can use it in such a way that it retrieves command-line arguments information, exit codes information, 2 min read C# Program to Get the Full Path of the Current Directory Using Environment Class In C#, Environment Class provides information about the current platform and manipulates, the current platform. It is useful for getting and setting various operating system-related information. We can use it in such a way that it retrieves command-line arguments information, exit codes information, 2 min read C# Program to Get Number of Processors of Current Machine using Environment Class Environment Class provides information about the current platform and manipulates, the current platform. It is useful for getting and setting various operating system-related information. We can use it in such a way that retrieves command-line arguments information, exit codes information, environme 1 min read C# Program to Get the Logical Drives of Computer System Using Environment Class In C#, Environment Class provides information about the current platform and manipulates, the current platform. It is useful for getting and setting various operating system-related information. We can use it in such a way that it retrieves command-line arguments information, exit codes information, 2 min read C# Program to Get the Network Domain Name Associated with Current Using Environment Class In C#, Environment Class provides information about the current platform and manipulates, the current platform. It is useful for getting and setting various operating system-related information. We can use it in such a way that it retrieves command-line arguments information, exit codes information, 2 min read Like