Programming Articles

Page 799 of 2547

CharEnumerator.Dispose() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 166 Views

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 More

DateTime.GetTypeCode() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 129 Views

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 More

Uri.CheckHostName(String) Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 484 Views

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 More

What are floating point literals in C#?

Ankith Reddy
Ankith Reddy
Updated on 17-Mar-2026 1K+ Views

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 More

Mutation Testing in C#

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 305 Views

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 More

SortedMap Interface in C#

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

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 More

How to create custom attributes in C#?

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 362 Views

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 More

Uri.CheckSchemeName(String) Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 204 Views

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 More

Print with your own font using C#

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 556 Views

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 More

Date format validation using C# Regex

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 16K+ Views

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
Showing 7981–7990 of 25,466 articles
« Prev 1 797 798 799 800 801 2547 Next »
Advertisements