AmitDiwan

AmitDiwan

8,392 Articles Published

Articles by AmitDiwan

Page 211 of 840

Single.GetTypeCode Method in C# with Examples

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 152 Views

The Single.GetTypeCode() method in C# is used to return the TypeCode for the Single value type (also known as float). This method is inherited from the IConvertible interface and always returns TypeCode.Single for any float value. Syntax Following is the syntax for the Single.GetTypeCode() method − public TypeCode GetTypeCode(); Return Value This method returns TypeCode.Single, which is an enumerated constant representing the Single data type. Using GetTypeCode with Different Float Values Example using System; public class Demo { public static void Main() { ...

Read More

How to find the MaxCapacity of a StringBuilder in C#?

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 312 Views

The MaxCapacity property of a StringBuilder in C# returns the maximum number of characters that the StringBuilder can hold. This is a read-only property that represents the theoretical upper limit for the StringBuilder's capacity. In most cases, the MaxCapacity is set to Int32.MaxValue (2, 147, 483, 647), which is the maximum value for a 32-bit signed integer. However, you can specify a custom maximum capacity when creating a StringBuilder using specific constructor overloads. Syntax Following is the syntax to access the MaxCapacity property − int maxCapacity = stringBuilder.MaxCapacity; Following is the syntax to ...

Read More

Stack.Pop() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 1K+ Views

The Stack.Pop() method in C# is used to remove and return the object at the top of the Stack. This method follows the LIFO (Last In, First Out) principle, where the most recently added element is the first one to be removed. Syntax Following is the syntax for the Pop() − public virtual object Pop(); Return Value The Pop() method returns the object that was removed from the top of the Stack. If the Stack is empty, it throws an InvalidOperationException. How Stack.Pop() Works Stack.Pop() Operation ...

Read More

OrderedDictionary Class in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 1K+ Views

The OrderedDictionary class in C# represents a collection of key/value pairs that maintains insertion order and allows access by both key and index. It combines the functionality of a dictionary with the ordered nature of a list, making it useful when you need to preserve the order of items while still providing fast key-based lookup. Syntax Following is the syntax for creating and using an OrderedDictionary − OrderedDictionary dict = new OrderedDictionary(); dict.Add(key, value); dict[key] = value; // Access by key dict[index] = value; // Access by index ...

Read More

Decimal.ToSingle() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 198 Views

The Decimal.ToSingle() method in C# is used to convert the value of the specified decimal to the equivalent single-precision floating-point number (float). This method is useful when you need to convert high-precision decimal values to float for mathematical operations or when interfacing with APIs that require float parameters. Syntax Following is the syntax − public static float ToSingle(decimal val); Parameters val − The decimal number to convert to a single-precision floating-point number. Return Value Returns a single-precision floating-point number (float) that is equivalent to the specified decimal value. Using Decimal.ToSingle() ...

Read More

Char.Parse(String) Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 4K+ Views

The Char.Parse(String) method in C# is used to convert the value of the specified string to its equivalent Unicode character. This method is particularly useful when you need to extract a single character from a string representation. Syntax Following is the syntax − public static char Parse(string s); Parameters s − A string that contains a single character, or null. Return Value Returns a Unicode character that is equivalent to the sole character in s. Examples Example 1: Parsing a Letter Character The following ...

Read More

Char.ToLowerInvariant(Char) Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 285 Views

The Char.ToLowerInvariant() method in C# is used to convert a Unicode character to its lowercase equivalent using the casing rules of the invariant culture. This method ensures consistent case conversion regardless of the current system culture, making it ideal for culture-independent operations. Syntax Following is the syntax − public static char ToLowerInvariant(char ch); Parameters ch − The Unicode character to convert to lowercase. Return Value Returns the lowercase equivalent of the specified character, or the same character if it has no lowercase equivalent or is already lowercase. ...

Read More

DateTimeOffset.AddSeconds() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 393 Views

The DateTimeOffset.AddSeconds() method in C# returns a new DateTimeOffset object that adds a specified number of whole and fractional seconds to the value of the current instance. This method is useful for time calculations where you need to preserve timezone offset information. Syntax Following is the syntax − public DateTimeOffset AddSeconds(double val); Parameters val − A double representing the number of seconds to add. It can be positive (to add seconds) or negative (to subtract seconds). Fractional values are allowed. Return Value Returns a new DateTimeOffset object whose value is the ...

Read More

Dictionary.Add() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 378 Views

The Dictionary.Add() method in C# is used to add a specified key-value pair to the dictionary. This method adds elements to the dictionary and throws an exception if you try to add a duplicate key. Syntax Following is the syntax − public void Add(TKey key, TValue value) Parameters key − The key of the element to add. Cannot be null. value − The value of the element to add. Can be null for reference types. Return Value This method does not return any value. It ...

Read More

Dictionary.Item[] Property in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 513 Views

The Dictionary.Item[] property in C# provides a convenient way to get or set values in a Dictionary using indexer syntax. This property allows you to access dictionary values directly using square bracket notation with the key, similar to array indexing. Syntax Following is the syntax for the Dictionary.Item[] property − public TValue this[TKey key] { get; set; } Parameters key − The key of the element to get or set. Return Value The property returns the value associated with the specified key. If the key is not found when ...

Read More
Showing 2101–2110 of 8,392 articles
« Prev 1 209 210 211 212 213 840 Next »
Advertisements