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
Char Struct in C#
The Char struct in C# represents a single Unicode character as a UTF-16 code unit. It provides numerous static methods for character classification, conversion, and comparison operations. The Char struct is a value type that implements IComparable, IConvertible, and IEquatable interfaces. Key Char Methods Method Description ConvertToUtf32(Char, Char) Converts the value of a UTF-16 encoded surrogate pair into a Unicode code point. ConvertToUtf32(String, Int32) Converts the value of a UTF-16 encoded character or surrogate pair at a specified position in a string into a Unicode code point. ...
Read MoreHow to convert XML to Json and Json back to XML using Newtonsoft.json?
Newtonsoft.Json (Json.NET) provides powerful methods for converting between XML and JSON formats. The library preserves all XML features including elements, attributes, text content, comments, character data, processing instructions, namespaces, and XML declarations during conversion. Required NuGet Package Install the Newtonsoft.Json package to use these conversion methods − Install-Package Newtonsoft.Json Key Methods The JsonConvert class provides two essential methods for XML-JSON conversion − SerializeXmlNode() − Converts XML to JSON format DeserializeXmlNode() − Converts JSON back to XML format Converting XML to JSON Use SerializeXmlNode() to convert an XmlDocument or ...
Read MoreTimeSpan.FromDays() Method in C#
The TimeSpan.FromDays() method in C# is used to create a TimeSpan object that represents a specified number of days. This static method is particularly useful when you need to work with time intervals measured in days and want to convert them to a TimeSpan for calculations or comparisons. Syntax Following is the syntax for the TimeSpan.FromDays() method − public static TimeSpan FromDays(double value); Parameters value: A double-precision floating-point number representing the number of days. The value can be positive, negative, or zero, and is accurate to the nearest millisecond. Return Value ...
Read MoreGet the minimum value in the SortedSet in C#
The SortedSet class in C# provides built-in properties to efficiently retrieve the minimum and maximum values. The Min property returns the smallest element, while the Max property returns the largest element in the sorted collection. Since SortedSet maintains elements in sorted order, accessing the minimum and maximum values is an O(1) operation, making it very efficient for scenarios where you frequently need these extreme values. Syntax Following is the syntax to get the minimum value from a SortedSet − T minValue = sortedSet.Min; Following is the syntax to get the maximum value from ...
Read MoreDouble.IsNaN() Method in C#
The Double.IsNaN() method in C# is used to determine whether a specified double value is "Not a Number" (NaN). This static method returns true if the value represents NaN, and false otherwise. NaN values typically result from invalid mathematical operations like dividing zero by zero. Syntax Following is the syntax for the Double.IsNaN() method − public static bool IsNaN(double val); Parameters val − A double-precision floating-point number to test. Return Value Returns true if the value is NaN; otherwise, false. Double.IsNaN() Results ...
Read MoreGet the number of elements actually contained in the ArrayList in C#
The Count property in C# is used to get the number of elements actually contained in an ArrayList. This property returns an integer representing the current number of elements, which is different from the Capacity property that indicates the total storage space available. Syntax Following is the syntax for using the Count property − int elementCount = arrayListName.Count; Count vs Capacity Count Property Capacity Property Returns the actual number of elements stored Returns the total storage space available Changes when elements are added or ...
Read MoreConvert Class in C#
The Convert class in C# provides static methods to convert between different base data types. It offers type-safe conversion methods that can handle null values and format providers, making it more robust than direct casting for many scenarios. The Convert class includes methods like ToBoolean(), ToDouble(), ToDecimal(), ToInt32(), and many others, each designed to convert values to their respective target types while handling edge cases and cultural formatting. Convert.ToBoolean() Method The Convert.ToBoolean() method converts a specified value to an equivalent Boolean value − Syntax public static bool ToBoolean(string value, IFormatProvider provider); public static bool ...
Read MoreHow to copy files into a directory in C#?
To copy files in C#, the File.Copy method is the primary approach. This method allows you to copy individual files from one location to another, with options to control whether existing files should be overwritten. Syntax The File.Copy method has two overloads − File.Copy(string sourceFileName, string destFileName) File.Copy(string sourceFileName, string destFileName, bool overwrite) Parameters sourceFileName − The file to copy. destFileName − The name of the destination file. This cannot be a directory. overwrite − true if the destination file should be overwritten if it already exists; otherwise, false. ...
Read MoreStack.Equals() Method in C#
The Stack.Equals() method in C# is used to check whether a Stack class object is equal to another object or not. This method performs reference equality, not content equality, meaning it returns true only if both variables reference the same Stack object in memory. Syntax Following is the syntax for the Stack.Equals() method − public virtual bool Equals(object obj); Parameters obj − The object to compare with the current Stack instance. Return Value Returns true if the specified object is the same instance as the current Stack; otherwise, false. ...
Read MoreDifference Between Delegates and Events in C#
In C#, both delegates and events are used for callback mechanisms, but they serve different purposes and have distinct characteristics. Understanding their differences is crucial for proper C# programming and design patterns. Delegates A delegate is a type that represents references to methods with a specific signature. It acts as a function pointer that can hold references to one or more methods during runtime. Syntax public delegate returnType DelegateName(parameters); Example using System; public delegate void MyDelegate(string message); public class DelegateExample { public static void Method1(string ...
Read More