karthikeya Boyini

karthikeya Boyini

1,421 Articles Published

Articles by karthikeya Boyini

Page 13 of 143

C# Program to Convert Integer to String

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

To convert an integer to string in C#, you can use several methods. The most common approach is the ToString() method, which provides a simple and direct way to convert any integer value to its string representation. Syntax Following is the syntax for using ToString() method − string result = number.ToString(); Alternative syntax using Convert.ToString() method − string result = Convert.ToString(number); Using ToString() Method The ToString() method is called on the integer variable to convert it to a string − using System; class Program { ...

Read More

What is the base class for all data types in C#.NET?

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

Object is the base class for all data types in C#. The Object Type is the ultimate base class for all data types in C# Common Type System (CTS). The object is an alias for System.Object class. When a value type is converted to object type, it is called boxing and on the other hand, when an object type is converted to a value type, it is called unboxing. Syntax Following is the syntax for declaring an object variable − object variableName; object variableName = value; Following is the syntax for boxing and ...

Read More

How to use NameValueCollection class in C#?

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 746 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 388 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 427 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

C# program to check if a Substring is present in a Given String

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

The Contains() method in C# is used to check if a substring is present within a given string. It returns a boolean value − true if the substring is found, and false otherwise. Syntax Following is the syntax for the Contains() method − bool result = string.Contains(substring); Parameters substring − The string to search for within the main string. Return Value The Contains()

Read More

How is an array initialized in C#?

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

All arrays consist of contiguous memory locations. The lowest address corresponds to the first element and the highest address to the last element. In C#, arrays must be properly initialized before you can use them to store and access data. Array Declaration vs Initialization Firstly, declare an array − int[] rank; But declaring an array does not initialize the array in the memory. When the array variable is initialized, you can assign values to the array. Array is a reference type, so you need to use the new keyword to create an instance ...

Read More

C# Console BufferWidth Property

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

The Console.BufferWidth property in C# gets or sets the width of the buffer area in columns. The buffer area is the region of memory that stores console output before it's displayed on the screen. This property is particularly useful when you need to control the console display width programmatically. Syntax Following is the syntax for getting the buffer width − int width = Console.BufferWidth; Following is the syntax for setting the buffer width − Console.BufferWidth = value; Return Value The property returns an int representing the width of the ...

Read More

C# program to check if two matrices are identical

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

In C#, to check whether two matrices are identical, you need to compare their dimensions first and then their corresponding elements. Two matrices are considered identical if they have the same dimensions and all corresponding elements are equal. Algorithm The algorithm for checking matrix equality involves the following steps − Compare the dimensions (rows and columns) of both matrices If dimensions don't match, the matrices cannot be identical If dimensions match, compare each corresponding element Use a flag to track if all elements are equal Matrix Comparison Process ...

Read More

C# Example for Single Inheritance

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

Single inheritance in C# allows a derived class to inherit from only one base class. This is the most common form of inheritance where a child class extends the functionality of its parent class by inheriting all accessible members and adding its own specific methods or properties. Syntax Following is the syntax for single inheritance in C# − class BaseClass { // base class members } class DerivedClass : BaseClass { // derived class members // inherits all accessible members from BaseClass } ...

Read More
Showing 121–130 of 1,421 articles
« Prev 1 11 12 13 14 15 143 Next »
Advertisements