Programming Articles

Page 862 of 2547

How to open hidden file using C#?

George John
George John
Updated on 17-Mar-2026 782 Views

To open a hidden file in C#, you need to first make it visible by removing the hidden attribute, then read its contents, and optionally restore the hidden attribute afterward. Hidden files have the FileAttributes.Hidden attribute set, which prevents them from being displayed in normal file explorers. Syntax Following is the syntax for removing the hidden attribute from a file − FileInfo file = new FileInfo(filePath); file.Attributes &= ~FileAttributes.Hidden; Following is the syntax for restoring the hidden attribute − file.Attributes |= FileAttributes.Hidden; Using FileInfo to Remove Hidden Attribute The ...

Read More

How to convert Trigonometric Angles in Radians using C#?

Samual Sam
Samual Sam
Updated on 17-Mar-2026 3K+ Views

To convert trigonometric angles from degrees to radians in C#, multiply the degree value by Math.PI/180. Most trigonometric functions in C# expect angles in radians, so this conversion is essential for accurate calculations. Syntax Following is the syntax for converting degrees to radians − double radians = degrees * (Math.PI / 180.0); Following is the syntax for converting radians to degrees − double degrees = radians * (180.0 / Math.PI); Converting Degrees to Radians Example The following example shows how to properly convert degrees to radians before using ...

Read More

Quickly convert Decimal to other bases in C#

Ankith Reddy
Ankith Reddy
Updated on 17-Mar-2026 797 Views

Converting decimal numbers to other bases in C# can be efficiently accomplished using a Stack data structure. The stack naturally handles the reversal of digits that occurs during the conversion process, making it an ideal choice for base conversion algorithms. How It Works The conversion process involves repeatedly dividing the decimal number by the target base and storing the remainders. Since division produces digits in reverse order, a stack helps retrieve them in the correct sequence: Divide the decimal number by the target base Push the remainder onto the stack Update the number to the quotient ...

Read More

What is the C# equivalent for the Java System.exit(0)?

Ankith Reddy
Ankith Reddy
Updated on 17-Mar-2026 2K+ Views

The C# equivalent for Java's System.exit(0) is the Environment.Exit() method. This method terminates the current process and returns an exit code to the operating system, just like its Java counterpart. Syntax Following is the syntax for using Environment.Exit() − Environment.Exit(exitCode); Parameters exitCode − An integer value returned to the operating system. Use 0 to indicate successful termination, and non-zero values to indicate different error conditions. Exit Code Conventions Exit Code Meaning 0 Process completed successfully 1 General error ...

Read More

DirectoryNotFoundException in C#

Samual Sam
Samual Sam
Updated on 17-Mar-2026 922 Views

The DirectoryNotFoundException in C# is thrown when an application attempts to access a directory that does not exist on the file system. This exception is part of the System.IO namespace and commonly occurs during file and directory operations. Syntax The exception is automatically thrown by the .NET framework when directory operations fail − public class DirectoryNotFoundException : SystemException Common methods that can throw this exception include − Directory.GetDirectories(path); Directory.GetFiles(path); DirectoryInfo directoryInfo = new DirectoryInfo(path); When DirectoryNotFoundException Occurs Here is an example that demonstrates when this exception occurs by trying ...

Read More

Complex Numbers in C#

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 4K+ Views

A complex number in C# consists of two components: a real part and an imaginary part. For example, in the complex number 7+5i, the real part is 7 and the imaginary part is 5 (the coefficient of i). C# allows you to create custom data structures to represent complex numbers using struct and implement mathematical operations using operator overloading. Syntax Following is the syntax for creating a complex number structure − public struct Complex { public double real; public double imaginary; public ...

Read More

What is the C# equivalent of C++ friend keyword?

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 3K+ Views

In C++, the friend keyword allows external functions or classes to access private and protected members of a class. C# does not have a direct equivalent to the friend keyword, but there are several approaches to achieve similar functionality. Understanding the friend Concept A friend function in C++ is defined outside a class but has access to all private and protected members of that class. While C# doesn't support this directly, it provides alternative mechanisms to control access between closely related classes. Using Nested Classes The closest equivalent to C++ friend functionality is using nested classes. ...

Read More

Compilation and Execution of a C# Program

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 22K+ Views

To compile and execute a program in C#, you can use several methods depending on your development environment. The most common approaches include using Visual Studio IDE, command-line tools, or online compilers. Using Visual Studio IDE In Microsoft Visual Studio IDE, compilation and execution is straightforward − Click the Run button or press F5 key to build and execute the project. Visual Studio automatically compiles your code and runs the executable. Any compilation errors will appear in the Error List window. Command-Line Compilation You can compile C# programs using the command-line C# compiler ...

Read More

C# program to print all the numbers divisible by 3 and 5 for a given number

Samual Sam
Samual Sam
Updated on 17-Mar-2026 6K+ Views

To print numbers divisible by both 3 and 5, we use the modulus operator % with the logical AND operator &&. A number is divisible by both 3 and 5 if the remainder is zero when divided by each of these numbers. Syntax Following is the syntax to check if a number is divisible by both 3 and 5 − if (num % 3 == 0 && num % 5 == 0) { // number is divisible by both 3 and 5 } Alternatively, since a number divisible by both 3 ...

Read More

How to convert a JavaScript array to C# array?

Ankith Reddy
Ankith Reddy
Updated on 17-Mar-2026 2K+ Views

Converting a JavaScript array to a C# array involves passing the JavaScript array data to your C# application, typically through web forms, AJAX requests, or by converting the array to a string format that C# can parse. The most common approach is to serialize the JavaScript array to a string (usually comma-separated or JSON format) and then parse it in C# to recreate the array. Using Comma-Separated String Conversion First, convert the JavaScript array to a comma-separated string using the join() method − var myArr = ["Welcome", "to", "the", "Web", "World"]; ...

Read More
Showing 8611–8620 of 25,466 articles
« Prev 1 860 861 862 863 864 2547 Next »
Advertisements