Samual Sam

Samual Sam

1,507 Articles Published

Articles by Samual Sam

Page 25 of 151

C# Program to display priority of Thread

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

In C#, thread priority determines how the operating system schedules threads for execution. The Priority property of the Thread class allows you to both view and set the priority of a thread. Thread priority is represented by the ThreadPriority enumeration. Syntax To get the current thread and display its priority − Thread thread = Thread.CurrentThread; ThreadPriority priority = thread.Priority; To set a thread's priority − thread.Priority = ThreadPriority.High; ThreadPriority Enumeration Values Priority Level Description Lowest The thread has the lowest priority ...

Read More

Manipulate decimals with numeric operators in C#

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

The decimal data type in C# provides precise arithmetic operations for financial and monetary calculations. You can manipulate decimals using standard numeric operators such as +, -, *, /, and %. Decimal literals in C# must be suffixed with M or m to distinguish them from double values. This ensures precision is maintained during calculations. Syntax Following is the syntax for declaring decimal variables − decimal variableName = value M; Following is the syntax for basic arithmetic operations with decimals − decimal result = decimal1 + decimal2; // Addition decimal ...

Read More

What is the difference between a float, double and a decimal in C#?

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

Float, double, and decimal are all value types in C# that represent numeric data with fractional parts. Each type differs in precision, memory size, and intended use cases. Understanding these differences is crucial for choosing the appropriate type for your specific needs. Syntax Following is the syntax for declaring float, double, and decimal variables − float floatValue = 3.14f; // 'f' suffix required double doubleValue = 3.14; // default for literals decimal decimalValue = 3.14m; // 'm' suffix required Float Value Type Float ...

Read More

Recommended IDEs for C# on Windows/Linux/Mac OS

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

Choosing the right IDE is crucial for productive C# development. While Microsoft Visual Studio remains the gold standard on Windows, developers have excellent options across all major operating systems including Windows, Linux, and macOS. Microsoft Visual Studio (Windows) Visual Studio is the flagship IDE for C# development on Windows, offering comprehensive tools for building desktop, web, and mobile applications. Visual Studio Features IntelliSense Code completion Error detection Quick fixes Debugging Breakpoints Variable inspection ...

Read More

Represent Int64 as a String in C#

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

The Int64 data type in C# represents a 64-bit signed integer that can hold values from -9, 223, 372, 036, 854, 775, 808 to 9, 223, 372, 036, 854, 775, 807. Converting an Int64 to a string is a common operation that can be accomplished using several methods, with ToString() being the most straightforward approach. Syntax The basic syntax for converting an Int64 to string using ToString() method − long variable = value; string result = variable.ToString(); You can also use format specifiers with ToString() − string result = variable.ToString("format"); ...

Read More

Abort in C#

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

The Thread.Abort() method in C# is used to forcibly terminate a thread by throwing a ThreadAbortException. This method was commonly used in older versions of .NET Framework but is now deprecated and not supported in .NET Core and .NET 5+. Important Note: Thread.Abort() is considered unsafe and unreliable. Modern C# applications should use cooperative cancellation with CancellationToken instead. Syntax Following is the syntax for using Thread.Abort() − thread.Abort(); The method throws a ThreadAbortException that can be caught, but the thread will still terminate − try { // thread ...

Read More

C# program to find node in Linked List

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

The LinkedList class in C# provides methods to search for nodes within the list. The Find() method returns the first LinkedListNode that contains the specified value, or null if the value is not found. Syntax Following is the syntax for finding a node in a LinkedList − LinkedListNode node = linkedList.Find(value); Following is the syntax for finding the last occurrence of a node − LinkedListNode node = linkedList.FindLast(value); Return Value The Find() method returns a LinkedListNode object containing the value, or null if the value is not found. The ...

Read More

What are static members of a C# Class?

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

Static members in C# belong to the class itself rather than to any specific instance of the class. When you declare a member as static, only one copy exists regardless of how many objects are created from the class. Static members are accessed using the class name directly, without creating an instance. They are commonly used for utility functions, constants, and shared data that should be consistent across all instances of a class. Syntax Following is the syntax for declaring static members − public static dataType memberName; public static returnType MethodName() { ...

Read More

"." custom specifier in C#

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

The "." custom format specifier in C# adds a localized decimal separator into the output string. It determines the exact position where the decimal point will appear in the formatted numeric value. The first period in the format string determines the location of the decimal separator in the formatted value. Any additional periods are ignored and treated as literal characters. Syntax Following is the syntax for using the "." custom format specifier − number.ToString("format_with_decimal_point") String.Format("format_with_decimal_point", number) Where the format string contains a period (.) to specify decimal separator placement. How It Works ...

Read More

What is the default access for a class in C#?

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

In C#, when no access modifier is specified for a class, the default access level is internal. An internal class can be accessed from any code within the same assembly but is not accessible from other assemblies. This means that classes declared without an explicit access modifier are visible throughout the current project or assembly, but remain hidden from external assemblies that might reference your code. Syntax Following is the syntax for declaring a class with different access levels − // Default access (internal) class MyClass { } // Explicitly internal internal class MyClass ...

Read More
Showing 241–250 of 1,507 articles
« Prev 1 23 24 25 26 27 151 Next »
Advertisements