Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles on Trending Technologies
Technical articles with clear explanations and examples
MathF.Floor() Method in C# with Examples
The MathF.Floor() method in C# returns the largest integer that is less than or equal to a specified float value. This method performs a floor operation, effectively rounding down to the nearest integer for positive numbers and rounding away from zero for negative numbers. Syntax Following is the syntax for the MathF.Floor() method − public static float Floor(float val); Parameters val: A single-precision floating-point number for which to find the floor value. Return Value Returns a float value representing the largest integer less than or equal to the input value. If ...
Read MoreGet a value indicating whether this instance is equal to a specified object or UInt64 in C#
The UInt64.Equals() method in C# determines whether the current UInt64 instance is equal to a specified object or another UInt64 value. This method returns true if the values are equal, otherwise false. The Equals() method is inherited from the Object class and overridden in the UInt64 structure to provide value-based comparison rather than reference comparison. Syntax Following is the syntax for the UInt64.Equals() method − public bool Equals(object obj) public bool Equals(ulong value) Parameters obj − The object to compare with the current instance. value − A UInt64 ...
Read MoreWhat is the difference between Select and SelectMany in Linq C#?
The Select and SelectMany operators in LINQ C# serve different purposes for data projection. Select produces one result value for every source element, while SelectMany belongs to Projection Operators category and is used to project each element of a sequence to an IEnumerable and flattens the resulting sequences into one sequence. Syntax Following is the syntax for Select operator − IEnumerable Select( this IEnumerable source, Func selector ) Following is the syntax for SelectMany operator − IEnumerable SelectMany( this IEnumerable source, ...
Read MoreHow to get a path to the desktop for current user in C#?
The desktop path of the current user can be fetched using Environment.GetFolderPath() with the Environment.SpecialFolder.Desktop enumeration. This method provides a reliable, cross-platform way to access special system folders. Syntax Following is the syntax for getting the desktop path − string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); The Environment.GetFolderPath() method takes an Environment.SpecialFolder enumeration value and returns the path to that special folder as a string. Parameters The method accepts the following parameter − folder − An Environment.SpecialFolder enumeration value that identifies the special folder whose path is to be retrieved. Return ...
Read MoreSingle.IsInfinity() Method in C# with Example
The Single.IsInfinity() method in C# is used to determine whether a single-precision floating-point number represents positive or negative infinity. This method is particularly useful when performing mathematical operations that might result in infinite values, such as division by zero. Syntax Following is the syntax for the Single.IsInfinity() method − public static bool IsInfinity(float val); Parameters val − A single-precision floating-point number to be tested for infinity. Return Value The method returns true if the specified value evaluates to positive or negative infinity; otherwise, false. Single.IsInfinity() Method ...
Read MoreCheck if SortedDictionary contains the specified key or not in C#
To check if a SortedDictionary contains a specified key, C# provides the ContainsKey() method. This method returns true if the key exists in the dictionary, otherwise false. The SortedDictionary maintains its elements in sorted order by key, making key lookups efficient with O(log n) time complexity. Syntax Following is the syntax for the ContainsKey() method − public bool ContainsKey(TKey key) Parameters key − The key to locate in the SortedDictionary. Return Value Returns true if the SortedDictionary contains an element with the specified key; otherwise, false. Using ContainsKey() ...
Read MoreGet the HashCode for the current UInt64 instance in C#
The GetHashCode() method in C# returns a hash code for the current UInt64 instance. Hash codes are primarily used in hash tables and dictionaries to quickly locate objects. For UInt64 values, the hash code is typically derived from the numeric value itself. Syntax Following is the syntax for getting the hash code of a UInt64 instance − public override int GetHashCode() Return Value The method returns a 32-bit signed integer hash code representing the current UInt64 value. Using GetHashCode() with Small Values For smaller UInt64 values that fit within the range ...
Read MoreHow many destructors can we have in one class in C#?
In C#, a destructor is a special method used to clean up resources when an object is destroyed. The answer to how many destructors a class can have is simple: only one destructor per class. Destructors are also called finalizers because they are automatically converted to Finalize() method calls by the compiler. Syntax Following is the syntax for declaring a destructor − class ClassName { ~ClassName() { // cleanup code } } Properties of Destructors Destructors do not ...
Read MoreWhat is Liskov Substitution principle and how to implement in C#?
The Liskov Substitution Principle (LSP) is one of the five SOLID principles in object-oriented programming. It states that derived types must be completely substitutable for their base types without altering the correctness of the program. In other words, objects of a superclass should be replaceable with objects of its subclasses without breaking the application. Definition According to LSP, we should be able to treat a child class as though it were the parent class. This means that all derived classes should retain the functionality of their parent class and cannot replace any functionality the parent provides in a ...
Read MoreQueue.GetEnumerator() Method in C#
The Queue.GetEnumerator() method in C# returns an IEnumerator object that allows you to iterate through the elements of a Queue in FIFO (First In, First Out) order. This method is essential for implementing custom iteration logic or using the Queue in foreach loops. Syntax Following is the syntax for the GetEnumerator() method − public virtual System.Collections.IEnumerator GetEnumerator(); Return Value The method returns an IEnumerator object that can iterate through the Queue elements from the front to the rear. Using GetEnumerator() with While Loop The most common way to use GetEnumerator() is ...
Read More