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
C# Enum ToString() Method
The ToString() method in C# enums converts the enum value to its equivalent string representation. This method provides different formatting options to display enum values as either their names or underlying numeric values. Syntax Following are the common syntax forms for enum ToString() method − enumValue.ToString() // Returns name enumValue.ToString("G") // Returns name (General format) enumValue.ToString("d") // Returns decimal value enumValue.ToString("D") // Returns decimal value Parameters ...
Read MoreWhat are accessors of properties in C#?
Properties are an extension of fields and are accessed using the same syntax. They use accessors through which the values of the private fields can be read, written or manipulated. The accessor of a property contains the executable statements that help in getting (reading or computing) or setting (writing) the property. Properties provide a controlled way to access class fields while maintaining encapsulation. Syntax Following is the syntax for property accessors in C# − public datatype PropertyName { get { return fieldName; } ...
Read MoreType.Equals() Method in C#
The Type.Equals() method in C# determines if the underlying system type of the current Type is the same as the underlying system type of the specified Object or Type. This method is essential for type comparison operations in reflection scenarios. Syntax The Type.Equals() method has two overloads − public virtual bool Equals(Type o); public override bool Equals(object o); Parameters o − The object or Type whose underlying system type is to be compared with the underlying system type of the current Type. Return Value Returns true if ...
Read MoreMath.Ceiling() Method in C#
The Math.Ceiling() method in C# returns the smallest integer value that is greater than or equal to the specified number. This method always rounds up to the next whole number, making it useful for scenarios where you need to ensure a minimum integer value. Syntax The Math.Ceiling() method has two overloads − public static decimal Ceiling(decimal val); public static double Ceiling(double val); Parameters val − The decimal or double number to be rounded up to the nearest integer. Return Value Returns the smallest integer value greater than ...
Read MoreInt64.GetTypeCode Method in C# with Examples
The Int64.GetTypeCode() method in C# is used to return the TypeCode for value type Int64. This method is inherited from the IConvertible interface and returns TypeCode.Int64 for all 64-bit signed integer values. Syntax Following is the syntax − public TypeCode GetTypeCode(); Return Value This method returns TypeCode.Int64, which is the enumerated constant representing the Int64 type. Using GetTypeCode() with Different Values Example Let us see an example to implement the Int64.GetTypeCode() method − using System; public class Demo { public static void Main() { ...
Read MoreMutation Test tools in C#
Mutation testing is a software testing technique that evaluates the quality of your test suite by introducing small code changes (mutations) and checking if your tests can detect these changes. In C#, several tools are available to perform mutation testing effectively. What is Mutation Testing? Mutation testing works by creating mutants − modified versions of your source code with small, intentional bugs. A good test suite should detect these mutations and fail when run against the mutated code. The mutation score represents the percentage of mutants killed (detected) by your tests. Mutation Testing ...
Read MoreC# program to merge two Dictionaries
Merging dictionaries in C# involves combining two or more Dictionary objects into one. This can be useful when you need to consolidate data from different sources or combine configuration settings. There are several approaches to merge dictionaries, each with different behaviors for handling duplicate keys. Syntax Following is the syntax for creating dictionaries − Dictionary dict = new Dictionary(); Following is the syntax for adding elements − dict.Add(key, value); dict[key] = value; // overwrites if key exists Using HashSet to Merge Keys Only This approach merges only the ...
Read MoreGet the range of elements in a C# list
The GetRange() method in C# is used to extract a subset of elements from a List. This method returns a new list containing the specified range of elements from the original list, without modifying the original list. Syntax Following is the syntax for the GetRange() method − public List GetRange(int index, int count) Parameters index − The zero-based starting index of the range to extract. count − The number of elements to extract from the starting index. Return Value Returns a new List containing the specified range of elements. ...
Read MoreC# Enum Parse Method
The Enum.Parse method in C# converts the string representation of an enum constant name or its numeric value into an equivalent enumerated object. This method is essential when you need to convert string data back into strongly-typed enum values. Syntax Following are the main syntax forms for Enum.Parse − // Basic syntax public static object Parse(Type enumType, string value) // With ignore case option public static object Parse(Type enumType, string value, bool ignoreCase) Parameters enumType − The type of the enumeration to parse to value − A string containing the name ...
Read MoreWhat are Add, Remove methods in C# lists?
The List is a generic collection in C# that provides dynamic array functionality. The Add() and Remove() methods are fundamental operations for managing elements in a list, allowing you to add new items and remove existing ones efficiently. Syntax Following is the syntax for adding elements to a list − List listName = new List(); listName.Add(item); Following is the syntax for removing elements from a list − bool result = listName.Remove(item); listName.RemoveAt(index); Using Add() Method The Add() method appends an element to the end of the list. It increases ...
Read More