Programming Articles

Page 821 of 2547

Represent Int32 as a Octal String in C#

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

To represent Int32 as an octal string in C#, use the Convert.ToString() method with base 8 as the second parameter. An Int32 represents a 32-bit signed integer that can hold values from -2, 147, 483, 648 to 2, 147, 483, 647. Syntax Following is the syntax for converting an Int32 to octal string − Convert.ToString(intValue, 8) Parameters intValue − The integer value to convert. 8 − The base for octal representation. Return Value The method returns a string representing the integer in octal format (base ...

Read More

How to use the GetValue() method of array class in C#?

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

The GetValue() method of the Array class in C# retrieves the value at a specified position in a multi-dimensional or single-dimensional array. This method is particularly useful when working with arrays created using Array.CreateInstance(), as it provides a generic way to access array elements regardless of the array's underlying type. Syntax Following is the syntax for using GetValue() with different array dimensions − // For single-dimensional array object value = array.GetValue(index); // For multi-dimensional array object value = array.GetValue(index1, index2); object value = array.GetValue(index1, index2, index3); Parameters index − A 32-bit ...

Read More

CharEnumerator.MoveNext() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 430 Views

The CharEnumerator.MoveNext() method in C# advances the internal index of the current CharEnumerator object to the next character of the enumerated string. It returns true if the enumerator successfully moved to the next character, or false if it has passed the end of the string. Syntax public bool MoveNext(); Return Value The method returns a bool value − true − if the enumerator was successfully advanced to the next character false − if the enumerator has passed the end of the string ...

Read More

Math.Sign() Method in C#

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

The Math.Sign() method in C# is used to return an integer that indicates the sign of a number. It returns +1 for positive numbers, -1 for negative numbers, and 0 for zero. Syntax The Math.Sign() method has multiple overloads to handle different numeric types − public static int Sign(sbyte value); public static int Sign(short value); public static int Sign(int value); public static int Sign(long value); public static int Sign(float value); public static int Sign(double value); public static int Sign(decimal value); Return Value The method returns an int value − -1 if ...

Read More

C# and Multiple Inheritance

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

C# does not support multiple inheritance of classes, meaning a class cannot inherit from more than one base class directly. However, C# provides interfaces to achieve similar functionality to multiple inheritance by allowing a class to implement multiple interfaces. Multiple inheritance allows a class to inherit features from multiple parent classes. While this can be powerful, it can also lead to complexity and ambiguity, which is why C# chose to support only single inheritance of classes. Why Multiple Inheritance is Not Supported C# avoids multiple class inheritance to prevent the diamond problem, where ambiguity arises when two ...

Read More

How is a new object created in C#?

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

In C#, creating objects is fundamental to object-oriented programming. An object is an instance of a class that represents a real-world entity. Objects allow you to access class members including fields, properties, and methods using the dot operator. Syntax Following is the basic syntax for creating a new object in C# − ClassName objectName = new ClassName(); You can also initialize an object with constructor parameters − ClassName objectName = new ClassName(parameter1, parameter2); Object Creation Process When you create an object using the new keyword, the following steps occur: ...

Read More

How to use NameValueCollection class in C#?

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

The NameValueCollection class in C# is a specialized collection that allows storing multiple values for a single key. It belongs to the System.Collections.Specialized namespace and is particularly useful for handling web form data, query strings, and HTTP headers where duplicate keys might exist. Unlike regular dictionaries that allow only one value per key, NameValueCollection can associate multiple string values with a single string key, making it ideal for scenarios like handling multiple form inputs with the same name. Syntax Following is the basic syntax for creating and using a NameValueCollection − NameValueCollection collection = new ...

Read More

Write a C# program to solve FizzBuzz problem

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

The FizzBuzz problem is a classic programming exercise that tests basic conditional logic and loop implementation. The problem requires printing numbers from 1 to 100 with specific substitutions based on divisibility rules. Problem Statement The FizzBuzz problem states that − Display "Fizz" instead of the number for each multiple of 3 Display "Buzz" instead of the number for each multiple of 5 Display "FizzBuzz" instead of the number for each multiple of both 3 and 5 Display the number itself if it's not a multiple of 3 or 5 FizzBuzz ...

Read More

C# Orderby Descending

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

The orderby descending clause in C# is used with LINQ to sort collections in descending order. It works with both query syntax and method syntax, allowing you to sort objects by any property or field. Syntax Following is the syntax for using orderby descending with LINQ query syntax − var result = from item in collection orderby item.Property descending select item; Following is the syntax for ...

Read More

What are finalizers in C#?

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

Finalizers in C# are special methods that perform cleanup when an object is being destroyed by the garbage collector. They provide a way to release unmanaged resources before the object is removed from memory. Syntax Following is the syntax for declaring a finalizer − ~ClassName() { // cleanup code here } The finalizer declaration uses a tilde (~) followed by the class name with no parameters or access modifiers. Key Rules Only one finalizer is allowed per class. Finalizers cannot be inherited or overloaded. ...

Read More
Showing 8201–8210 of 25,466 articles
« Prev 1 819 820 821 822 823 2547 Next »
Advertisements