Csharp Articles

Page 51 of 196

Get the TypeCode for value type Int16 in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 178 Views

The GetTypeCode() method in C# returns a TypeCode enumeration that identifies the type of a value. For Int16 (short) values, this method consistently returns TypeCode.Int16 regardless of the actual numeric value stored. Syntax Following is the syntax for getting the TypeCode of an Int16 value − TypeCode typeCode = int16Variable.GetTypeCode(); Return Value The GetTypeCode() method returns TypeCode.Int16 for all short variables, which represents the 16-bit signed integer type. Using GetTypeCode() with Int16 Values Example using System; public class Demo { public static void Main() { ...

Read More

Find the last node in LinkedList containing the specified value in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 205 Views

The FindLast() method in C# LinkedList is used to find the last occurrence of a node containing the specified value. This method searches from the end of the LinkedList towards the beginning and returns the last LinkedListNode that contains the specified value. Syntax Following is the syntax for the FindLast() method − public LinkedListNode FindLast(T value) Parameters value − The value to locate in the LinkedList. Return Value Returns the last LinkedListNode that contains the specified value, or null if the value is not found. Using FindLast() with ...

Read More

Get a specific type nested within the current Type in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 147 Views

The GetNestedType() method in C# is used to retrieve a specific nested type (inner class) from within the current type. This method is part of the Type class and helps in reflection scenarios where you need to access inner classes dynamically. Syntax Following is the syntax for the GetNestedType() method − public Type GetNestedType(string name) public Type GetNestedType(string name, BindingFlags bindingAttr) Parameters name − The name of the nested type to retrieve. bindingAttr − Optional. Specifies how the search is conducted (public, non-public, etc.). Return Value Returns a Type ...

Read More

Get the types nested within the current Type C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 218 Views

To get the types nested within the current Type in C#, you can use the GetNestedTypes() method. This method returns an array of Type objects representing all nested types (classes, interfaces, structs, etc.) defined within a type. Syntax Following is the syntax for getting nested types − Type[] nestedTypes = type.GetNestedTypes(); To specify visibility, use the overload with BindingFlags − Type[] nestedTypes = type.GetNestedTypes(BindingFlags.Public | BindingFlags.NonPublic); Using GetNestedTypes() Method The GetNestedTypes() method retrieves all public nested types by default. Here's a basic example − Example using ...

Read More

How to get Synchronize access to the StringCollection in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 125 Views

The StringCollection class in C# is not thread-safe by default. To achieve synchronized access in multi-threaded environments, you can use the SyncRoot property combined with a lock statement to ensure thread-safe operations. The SyncRoot property returns an object that can be used to synchronize access to the collection, preventing multiple threads from modifying or accessing the collection simultaneously. Syntax Following is the syntax for synchronized access to StringCollection − lock(stringCollection.SyncRoot) { // thread-safe operations on stringCollection } Why Synchronization is Needed In multi-threaded applications, multiple threads may try to ...

Read More

Check whether the specified character has a surrogate code in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 270 Views

In C#, a surrogate is a character that represents a Unicode code point outside the Basic Multilingual Plane (BMP). Surrogate characters are used to encode Unicode characters that require more than 16 bits, using a pair of 16-bit values called high surrogate and low surrogate. The Char.IsSurrogate() method checks whether a character at a specified position in a string is a surrogate character. Syntax Following is the syntax for checking surrogate characters − bool result = Char.IsSurrogate(string, index); bool result = Char.IsSurrogate(char); Parameters string − The string containing the character ...

Read More

Get the hyperbolic arc-cosine of a floating-point value in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 201 Views

To get the hyperbolic arc-cosine of a floating-point value in C#, you use the MathF.Acosh() method for float values or Math.Acosh() method for double values. The hyperbolic arc-cosine function returns the value whose hyperbolic cosine is the specified number. Syntax Following is the syntax for the hyperbolic arc-cosine methods − // For float values public static float Acosh(float x) // For double values public static double Acosh(double x) Parameters x − A number representing a hyperbolic cosine, where x must be greater than or equal to 1. ...

Read More

Get the angle whose sine is float value argument in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 208 Views

To get the angle whose sine is a float value argument in C#, we use the MathF.Asin() method. This method returns the arcsine (inverse sine) of the specified number in radians. The input value must be between -1 and 1, otherwise the method returns NaN (Not a Number). Syntax Following is the syntax for MathF.Asin() method − public static float Asin(float x) Parameters x − A number representing a sine value. Must be between -1 and 1 inclusive. Return Value Returns the arcsine of the specified number in radians. ...

Read More

Get the HashCode for the current UInt32 instance in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 177 Views

The GetHashCode() method in C# returns a hash code for the current UInt32 instance. This hash code is used internally by hash-based collections like Dictionary and HashSet for efficient storage and retrieval operations. For UInt32 values, the hash code is typically the value itself, making it straightforward to understand and predict. Syntax Following is the syntax for getting the hash code of a UInt32 instance − uint value = 100; int hashCode = value.GetHashCode(); Return Value The GetHashCode()

Read More

Fetch the maximum value from a MySQL column?

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 248 Views

To fetch the maximum value from a MySQL column in C#, you need to establish a database connection and execute a query using either the MAX() function or ORDER BY with LIMIT. This tutorial demonstrates both approaches using MySQL.Data.MySqlClient. Syntax Following is the syntax for fetching maximum value using the MAX() function − SELECT MAX(column_name) FROM table_name; Following is the syntax using ORDER BY with LIMIT − SELECT column_name FROM table_name ORDER BY column_name DESC LIMIT 1; Database Setup First, let us create a table and insert sample data ...

Read More
Showing 501–510 of 1,951 articles
« Prev 1 49 50 51 52 53 196 Next »
Advertisements