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
Programming Articles
Page 799 of 2547
CharEnumerator.Dispose() Method in C#
The CharEnumerator.Dispose() method in C# is used to release all resources used by the current instance of the CharEnumerator class. This method implements the IDisposable interface and should be called when you're finished using the enumerator to ensure proper resource cleanup. Syntax Following is the syntax for the CharEnumerator.Dispose() method − public void Dispose(); Parameters This method does not take any parameters. Return Value This method does not return any value (void). Using CharEnumerator.Dispose() Method Example 1: Basic Usage The following example demonstrates how to use the Dispose() ...
Read MoreDateTime.GetTypeCode() Method in C#
The DateTime.GetTypeCode() method in C# is used to return the TypeCode for the DateTime value type. The returned value is the enumerated constant TypeCode.DateTime. This method is inherited from the IConvertible interface and is primarily used in scenarios where you need to determine the type code of a DateTime object programmatically, such as in reflection or type conversion operations. Syntax Following is the syntax − public TypeCode GetTypeCode(); Return Value The method returns TypeCode.DateTime, which is an enumerated constant that represents the DateTime type. Using GetTypeCode() with Current DateTime The ...
Read MoreUri.CheckHostName(String) Method in C#
The Uri.CheckHostName() method in C# is used to determine the type of hostname specified in a string. It validates whether the given string represents a valid DNS name, IPv4 address, IPv6 address, or an unknown format. Syntax Following is the syntax − public static UriHostNameType CheckHostName(string hostName); Parameters hostName − A string that contains the hostname to validate. Return Value The method returns a UriHostNameType enumeration value that indicates the type of the hostname − UriHostNameType Description Dns Valid ...
Read MoreWhat are floating point literals in C#?
A floating-point literal in C# represents a decimal number that can contain a fractional part. It consists of an integer part, a decimal point, a fractional part, and optionally an exponent part. You can represent floating point literals in either decimal form or exponential form. Syntax Following are the different forms of floating-point literal syntax − // Decimal form 123.45 0.5678 // Exponential form 1.23E+2 // 1.23 × 10² 4.56e-3 // 4.56 × 10⁻³ // With type suffixes 3.14f // float 2.718 ...
Read MoreMutation Testing in C#
Mutation testing in C# is a technique for evaluating the quality of your test suite by introducing small changes (mutations) to your source code and checking if your tests can detect these changes. If a test fails when the code is mutated, it indicates the test is effective at catching bugs. The primary purpose of mutation testing is to identify weaknesses in your test suite and improve test coverage quality beyond simple line coverage metrics. How Mutation Testing Works Mutation testing follows a systematic process to evaluate test effectiveness − Mutation Testing ...
Read MoreSortedMap Interface in C#
In C#, there is no direct equivalent to Java's SortedMap interface. However, C# provides the SortedList and SortedDictionary collections which offer similar functionality for maintaining key-value pairs in sorted order. The SortedList collection in C# uses both a key and an index to access items. It combines the features of an array and a hash table, maintaining items in sorted order based on the key values. You can access items either by index (like an ArrayList) or by key (like a Hashtable). Syntax Following is the syntax for creating a SortedList − SortedList sortedList = ...
Read MoreHow to create custom attributes in C#?
Custom attributes in C# allow you to store declarative information about program elements (classes, methods, properties, etc.) that can be retrieved at runtime using reflection. They provide metadata that doesn't affect program execution but can be used for documentation, validation, or configuration purposes. Syntax Following is the basic syntax for creating a custom attribute − [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] public class CustomAttribute : System.Attribute { // constructors and properties } Following is the syntax for applying the custom attribute − [CustomAttribute(parameters)] public class MyClass { // class ...
Read MoreUri.CheckSchemeName(String) Method in C#
The Uri.CheckSchemeName() method in C# is used to determine whether the specified scheme name is valid. A valid scheme name must start with a letter and can contain only letters, digits, plus (+), period (.), or hyphen (-) characters. Syntax Following is the syntax − public static bool CheckSchemeName(string schemeName); Parameters schemeName − The scheme name to validate as a string. Return Value Returns true if the scheme name is valid; otherwise, false. Valid vs Invalid Scheme Names Valid ...
Read MorePrint with your own font using C#
To print with your own font in C#, you need to construct two essential objects: a FontFamily object and a Font object. The FontFamily object sets the typeface like Arial, Times New Roman, etc., whereas the Font object defines the size, style, and unit of measurement for the font. Syntax Following is the syntax for creating a FontFamily object − FontFamily fontFamily = new FontFamily("FontName"); Following is the syntax for creating a Font object − Font font = new Font(fontFamily, size, style, unit); Parameters The Font constructor accepts the ...
Read MoreDate format validation using C# Regex
Date format validation in C# ensures that user input matches the expected date format before processing. The most reliable approach is using the DateTime.TryParseExact method, which validates both the format and the actual date values. For more complex pattern matching, Regular Expressions (Regex) can also be used. Syntax Following is the syntax for DateTime.TryParseExact method − bool DateTime.TryParseExact(string s, string format, IFormatProvider provider, DateTimeStyles style, out DateTime result) Following is the syntax for Regex date validation − Regex regex = new Regex(@"pattern"); bool isMatch = regex.IsMatch(dateString); ...
Read More