karthikeya Boyini

karthikeya Boyini

1,420 Articles Published

Articles by karthikeya Boyini

Page 18 of 142

C# Orderby Descending

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 446 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 727 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 201 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 298 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 766 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

C# Linq SelectMany Method

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

The SelectMany method in C# LINQ is used to flatten collections of collections into a single sequence. It projects each element of a sequence to an IEnumerable and then flattens the resulting sequences into one sequence. Syntax Following is the basic syntax for SelectMany method − public static IEnumerable SelectMany( this IEnumerable source, Func selector ) Parameters source − The input sequence to transform. selector − A function that transforms each element into a collection. Return Value Returns an IEnumerable whose ...

Read More

How is an array declared in C#?

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

To declare an array in C#, you specify the data type followed by square brackets and the array name. Arrays in C# are reference types that store multiple elements of the same data type in a contiguous memory location. Syntax Following is the basic syntax for declaring an array − datatype[] arrayName; To declare and initialize an array with a specific size − datatype[] arrayName = new datatype[size]; To declare and initialize an array with values − datatype[] arrayName = {value1, value2, value3, ...}; Here − ...

Read More

C# Generics vs C++ Templates

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

C# Generics and C++ Templates both provide support for parameterized types, allowing you to write reusable code that works with different data types. However, they differ significantly in their design philosophy, capabilities, and implementation approaches. Key Differences Between C# Generics and C++ Templates Feature C# Generics C++ Templates Compilation Model Compile-time and run-time support Compile-time only Type Safety Strong type checking at compile-time Duck typing, errors at instantiation Specialization No explicit or partial specialization Full support for specialization Non-type Parameters Not supported Fully supported ...

Read More

How to use XmlSerializer in C#?

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

The XmlSerializer in C# is used to convert objects to XML format (serialization) and back to objects (deserialization). This allows you to store object data in XML files or transmit data between applications in a standardized XML format. XmlSerializer provides fine-grained control over how objects are encoded into XML, including element names, attributes, and namespaces through various attributes. Syntax Following is the syntax for creating an XmlSerializer instance − XmlSerializer serializer = new XmlSerializer(typeof(ClassName)); Following is the syntax for serializing an object to XML − using (StreamWriter writer = new StreamWriter(filePath)) ...

Read More
Showing 171–180 of 1,420 articles
« Prev 1 16 17 18 19 20 142 Next »
Advertisements