Programming Articles

Page 92 of 2547

MathF.Round() Method in C# with Examples

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

The MathF.Round() method in C# is used to round a float value to the nearest integer or to a specified number of fractional digits. This method provides several overloads to handle different rounding scenarios and midpoint rounding behaviors. Syntax Following are the different overloads of the MathF.Round() method − public static float Round(float x); public static float Round(float x, int digits); public static float Round(float x, int digits, MidpointRounding mode); public static float Round(float x, MidpointRounding mode); Parameters x − The float number to be rounded. digits − The number of fractional ...

Read More

Compare the content of two StringBuilders

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

The Equals method in C# is used to compare the content of two StringBuilder objects. This method performs a character-by-character comparison of the text content stored in both StringBuilder instances. Syntax Following is the syntax for comparing two StringBuilder objects − bool result = stringBuilder1.Equals(stringBuilder2); Parameters The Equals method takes one parameter − sb − The StringBuilder object to compare with the current instance. Return Value The method returns a bool value − true if both StringBuilder objects have the same content. ...

Read More

C# Program to get current day of week

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

Use the DateTime.DayOfWeek property to get the current day of the week in C#. This property returns a DayOfWeek enumeration value representing the day. Syntax Following is the syntax to get the current day of the week − DayOfWeek dayOfWeek = DateTime.Today.DayOfWeek; You can also use DateTime.Now.DayOfWeek to include the current time − DayOfWeek dayOfWeek = DateTime.Now.DayOfWeek; Using DateTime.Today.DayOfWeek The DateTime.Today property gets the current date with the time component set to 00:00:00. Using DayOfWeek on this returns the current day as an enumeration value − using ...

Read More

UInt64.GetTypeCode() Method in C# with Examples

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 144 Views

The UInt64.GetTypeCode() method in C# returns the TypeCode enumeration value for the UInt64 data type. This method is inherited from the IConvertible interface and helps identify the specific type of a value at runtime. The TypeCode enumeration provides a way to categorize the built-in .NET data types, making it useful for type checking and conversion operations. Syntax Following is the syntax − public TypeCode GetTypeCode(); Return Value This method always returns TypeCode.UInt64 for any ulong value, as all UInt64 instances belong to the same data type. Example Let us see ...

Read More

What are the differences between a multi-dimensional array and jagged array?

Samual Sam
Samual Sam
Updated on 17-Mar-2026 1K+ Views

Multi-dimensional arrays and jagged arrays are two different ways to work with nested data structures in C#. Understanding their differences is crucial for choosing the right approach for your specific use case. Multi-dimensional Arrays A multi-dimensional array is also called a rectangular array because all rows have the same number of columns, forming a rectangular structure. All sub-arrays must have identical lengths. Syntax Following is the syntax for declaring multi-dimensional arrays − // 2D array int[, ] array2D = new int[rows, columns]; // 3D array int[, , ] array3D = new ...

Read More

How to find the product of two binary numbers using C#?

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

To find the product of two binary numbers in C#, we can implement binary multiplication using the traditional algorithm. This involves multiplying each digit of one binary number with the other and adding the results with proper shifting. How Binary Multiplication Works Binary multiplication follows the same principle as decimal multiplication, but uses only 0 and 1. When we multiply by 1, we get the same number; when we multiply by 0, we get zero. The partial products are then added together with appropriate left shifts. Binary Multiplication Process 11100 (28 ...

Read More

Iterating C# StringBuilder in a foreach loop

Samual Sam
Samual Sam
Updated on 17-Mar-2026 2K+ Views

The StringBuilder class in C# is used for efficient string manipulation when dealing with multiple string operations. While StringBuilder itself is not directly iterable in a foreach loop, you can use foreach loops to iterate over collections and append elements to a StringBuilder. Syntax Following is the syntax for using foreach with StringBuilder − StringBuilder sb = new StringBuilder(); foreach (type item in collection) { sb.Append(item); } Using foreach to Build StringBuilder from Array You can iterate through a string array and append each element to a StringBuilder − ...

Read More

Generate current month in C#

George John
George John
Updated on 17-Mar-2026 11K+ Views

To generate the current month in C#, you can use the DateTime.Now property to get the current date and time, then extract the month information using various properties and formatting methods. Syntax Following is the syntax to get the current date − DateTime dt = DateTime.Now; Following is the syntax to get the month as a number − int month = dt.Month; Following is the syntax to get the month name using formatting − string monthName = dt.ToString("MMMM"); Getting Current Month as Number The Month ...

Read More

Type.GetInterface() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 275 Views

The Type.GetInterface() method in C# is used to get a specific interface implemented or inherited by the current Type. This method searches through all interfaces implemented by a type and returns the one that matches the specified name. Syntax Following are the overloads of the GetInterface() method − public Type GetInterface(string name); public abstract Type GetInterface(string name, bool ignoreCase); Parameters name − The name of the interface to find. ignoreCase − A Boolean value indicating whether to perform a case-insensitive search for the interface name. Return ...

Read More

What are the differences between a static and a non-static class in C#?

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 2K+ Views

A static class in C# cannot be instantiated and contains only static members, while a non-static class can be instantiated to create objects and can contain both static and instance members. The key difference is that static classes are designed for utility functions that don't require object state, whereas non-static classes represent entities that can have multiple instances with their own data. Syntax Following is the syntax for declaring a static class − public static class ClassName { public static void StaticMethod() { ...

Read More
Showing 911–920 of 25,467 articles
« Prev 1 90 91 92 93 94 2547 Next »
Advertisements