Samual Sam

Samual Sam

1,507 Articles Published

Articles by Samual Sam

Page 16 of 151

Convert.ToDouble Method in C#

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

The Convert.ToDouble() method in C# converts a specified value to a double-precision floating-point number. This method is part of the Convert class and can handle various data types including integers, strings, booleans, and other numeric types. Syntax Following is the syntax for the Convert.ToDouble() method − public static double ToDouble(object value) public static double ToDouble(string value) public static double ToDouble(int value) public static double ToDouble(long value) public static double ToDouble(bool value) Parameters value − The value to be converted to a double-precision floating-point number. This can be of various types including object, string, ...

Read More

Association, Composition and Aggregation in C#

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

In C#, object-oriented programming relies on relationships between classes to model real-world scenarios. Three fundamental types of relationships are Association, Composition, and Aggregation. These relationships define how objects interact and depend on each other. Object Relationships in C# Association "Uses-a" Loose coupling Aggregation "Has-a" Weak ownership Composition "Part-of" Strong ownership ...

Read More

Swap two Strings without using temp variable in C#

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

To swap two strings without using a temporary variable in C#, you can use string concatenation and the Substring() method. This technique works by combining both strings into one, then extracting the original values in reverse order. Algorithm The swapping process follows these three steps − Step 1: Append the second string to the first string. Step 2: Extract the original first string from the beginning and assign it to the second string variable. Step 3: Extract the original second string from the remaining part and assign it to the first string variable. ...

Read More

How to use the ?: conditional operator in C#?

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

The conditional operator (also called the ternary operator) is represented by the symbol ?:. It provides a concise way to write simple if-else statements in a single expression. The operator has right-to-left associativity and evaluates a boolean condition to return one of two possible values. Syntax Following is the syntax for the conditional operator − condition ? value_if_true : value_if_false Where: condition is an expression that evaluates to a boolean value value_if_true is returned if the condition is true value_if_false is returned if the condition is false How It Works ...

Read More

Boxing and Unboxing in C#

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

Boxing is the process of converting a value type to a reference type by wrapping it in an object. Unboxing is the reverse process — extracting the value type from the boxed object. These operations allow value types to be treated as objects when needed. Boxing and Unboxing Process Value Type int myVal = 12 Reference Type object myBoxed Boxing (Implicit) Unboxing (Explicit Cast) Stored on Stack ...

Read More

Command Line arguments in C#

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

Command line arguments in C# allow you to pass data to your program when it starts. These arguments are received through the string[] args parameter in the Main method, making your applications flexible and configurable from the command line. When you create a C# program, the Main method can accept command line arguments as an array of strings. Each argument passed from the command line becomes an element in this array. Syntax Following is the syntax for accepting command line arguments in the Main method − static void Main(string[] args) { // ...

Read More

Background Worker Class in C#

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

The BackgroundWorker class in C# allows you to run long-running operations on a separate thread while keeping the user interface responsive. It provides a simple way to execute tasks in the background and communicate with the main thread for progress updates and completion notifications. BackgroundWorker is particularly useful in Windows Forms applications where intensive tasks need to run without freezing the UI. It handles thread management automatically and provides events for progress reporting and task completion. Key Properties Property Description CancellationPending Indicates whether the application has requested cancellation of the ...

Read More

String Literal Vs String Object in C#

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

In C#, strings can be created using string literals or as string objects. Understanding the difference between these two approaches is important for memory management and performance optimization. String Literals String literals are constants enclosed in double quotes "" or prefixed with @"" for verbatim strings. They are stored in a special area of memory called the string pool, where identical string values are shared to save memory. Syntax Following is the syntax for string literals − string variableName = "string value"; string verbatimString = @"string with multiple lines or special characters"; ...

Read More

AsEnumerable() in C#

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

The AsEnumerable() method in C# is used to cast a specific type to its IEnumerable equivalent. It is an extension method from the System.Linq namespace that helps when you need to treat a collection as a basic enumerable sequence, often to force LINQ to Objects behavior over LINQ to SQL or Entity Framework queries. Syntax Following is the syntax for using AsEnumerable() − public static IEnumerable AsEnumerable(this IEnumerable source) Usage example − var enumerable = collection.AsEnumerable(); Parameters source − The sequence to type as IEnumerable. Return ...

Read More

BigInteger Class in C#

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

The BigInteger class in C# is designed to handle arbitrarily large integers that exceed the limits of standard integer types. It is part of the System.Numerics namespace and provides support for mathematical operations on very large numbers without overflow. Unlike built-in integer types like int or long, BigInteger can represent integers of any size, limited only by available memory. This makes it ideal for cryptographic calculations, mathematical computations, and scenarios requiring precise arithmetic with large numbers. Syntax The BigInteger structure declaration − [SerializableAttribute] public struct BigInteger : IFormattable, IComparable, IComparable, IEquatable Creating a ...

Read More
Showing 151–160 of 1,507 articles
« Prev 1 14 15 16 17 18 151 Next »
Advertisements