Programming Articles

Page 80 of 2547

File Permissions in C#

George John
George John
Updated on 17-Mar-2026 3K+ Views

File permissions in C# are managed using the FileIOPermission class from the System.Security.Permissions namespace. This class controls the ability to access files and folders by defining what operations are allowed on specific file system resources. The FileIOPermission class is part of .NET's Code Access Security (CAS) system and helps ensure that applications only perform file operations they are explicitly granted permission to execute. Syntax Following is the syntax for creating a FileIOPermission instance − FileIOPermission permission = new FileIOPermission(PermissionState.None); permission.AllLocalFiles = FileIOPermissionAccess.Read; Following is the syntax for adding specific path permissions − ...

Read More

The "E" and "e" custom specifiers in C#

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

The "E" and "e" custom specifiers in C# are used to format numbers in scientific notation (exponential notation). When any of these specifiers appear in a format string followed by at least one zero, the number is formatted with an "E" or "e" separator between the mantissa and the exponent. Syntax The following format specifiers create exponential notation − "E0" // Uppercase E with minimum exponent digits "e0" // Lowercase e with minimum exponent digits "E+0" // Uppercase E with explicit + sign "e+0" // Lowercase ...

Read More

Draw an ellipse in C#

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

To draw an ellipse in C#, you use the DrawEllipse() method from the Graphics class. This method requires a Pen object to define the ellipse's outline and either a Rectangle or coordinate parameters to specify the ellipse's position and size. Drawing ellipses is commonly done in Windows Forms applications using the Paint event handler or by overriding the OnPaint method. Syntax The DrawEllipse() method has several overloads − graphics.DrawEllipse(pen, rectangle); graphics.DrawEllipse(pen, x, y, width, height); Parameters pen − Defines the color, width, and style of the ellipse outline rectangle − Specifies ...

Read More

Char.ToString() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 210 Views

The Char.ToString() method in C# is used to convert a character to its equivalent string representation. This method is particularly useful when you need to convert a single character into a string for string operations or concatenation. Syntax Following is the syntax for the Char.ToString() method − public override string ToString(); Return Value The method returns a string object containing the character value converted to its string representation. Using Char.ToString() Method Example 1 - Converting Lowercase Character Let us see an example to convert a lowercase character to its string ...

Read More

DateTimeOffset.AddTicks() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 266 Views

The DateTimeOffset.AddTicks() method in C# is used to add a specified number of ticks to the value of a DateTimeOffset instance. A tick represents 100 nanoseconds, making it the smallest unit of time measurement in .NET. Syntax Following is the syntax − public DateTimeOffset AddTicks(long ticks); Parameters ticks: A signed 64-bit integer representing the number of 100-nanosecond ticks to add. To subtract ticks, use a negative value. Return Value Returns a new DateTimeOffset instance with the specified ticks added to the original value. The original instance remains unchanged. Understanding Tick ...

Read More

How to add items/elements to an existing jagged array in C#?

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

Adding items to an existing jagged array in C# can be accomplished through several methods. You can modify individual elements directly, replace entire sub-arrays, or dynamically resize arrays using collections. The approach depends on whether you want to change existing elements or expand the array structure. Understanding Jagged Arrays A jagged array is an array of arrays where each sub-array can have different lengths. Unlike multidimensional arrays, jagged arrays provide flexibility in storing data with varying row sizes. Jagged Array Structure arr[0] arr[1] ...

Read More

What is the Mutex class in C#?

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

The Mutex class in C# is a synchronization primitive that provides mutually exclusive access to a shared resource. Unlike other synchronization mechanisms, Mutex can be used for both thread synchronization within a single process and interprocess synchronization across multiple processes. The name "Mutex" stands for mutual exclusion, ensuring that only one thread can access a protected resource at a time. Syntax Following are the common ways to create a Mutex instance − // Default constructor Mutex mutex = new Mutex(); // With initial ownership Mutex mutex = new Mutex(bool initiallyOwned); // With initial ...

Read More

Pair Class in C#

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

The KeyValuePair structure in C# allows you to store a pair of related values as a single unit. It is commonly used in collections like Dictionary and can be used in lists to store paired data such as name-value combinations or key-identifier pairs. The KeyValuePair is a generic structure that provides a way to store two related pieces of data together, where TKey represents the key type and TValue represents the value type. Syntax Following is the syntax for creating a KeyValuePair − KeyValuePair pair = new KeyValuePair(key, value); Following is the syntax ...

Read More

C# Program to read all the lines of a file at once

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 239 Views

The File.ReadAllText() method in C# reads all the text from a file and returns it as a single string. This method is part of the System.IO namespace and provides a simple way to read entire file contents at once. When you need to read all lines from a text file in one operation, ReadAllText() is more efficient than reading line by line, especially for smaller files. Syntax Following is the syntax for the File.ReadAllText() method − public static string ReadAllText(string path); Parameters path − The file path to read from. Can ...

Read More

Chaining comparison operators in C#

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 690 Views

C# supports chaining comparison operators based on operator associativity and precedence. When multiple operators of the same precedence appear in an expression, they are evaluated according to their associativity rules, typically left-to-right. Understanding how comparison operators chain together is crucial for writing correct conditional expressions and avoiding logical errors in your code. Syntax Following is the basic syntax for chaining comparison operators − variable1 == variable2 == variable3 variable1 != variable2 != variable3 The evaluation follows left-to-right associativity − (variable1 == variable2) == variable3 How Operator Chaining Works ...

Read More
Showing 791–800 of 25,467 articles
« Prev 1 78 79 80 81 82 2547 Next »
Advertisements