karthikeya Boyini

karthikeya Boyini

1,421 Articles Published

Articles by karthikeya Boyini

Page 8 of 143

What are destructors in C# programs?

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

A destructor is a special member function of a class that is executed whenever an object of its class goes out of scope or is garbage collected. It performs cleanup operations before the object is destroyed from memory. A destructor has exactly the same name as the class with a prefixed tilde (~), and it cannot have parameters or return values. It is automatically called by the garbage collector, not directly by the programmer. Syntax Following is the syntax for declaring a destructor − ~ClassName() { // cleanup code } ...

Read More

C# program to copy a range of bytes from one array to another

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

The Buffer.BlockCopy method in C# is used to copy a range of bytes from one array to another. This method provides a fast, low-level approach for copying data between arrays and is particularly useful when working with byte arrays or when you need to copy a specific range of elements. Syntax Following is the syntax for the Buffer.BlockCopy method − Buffer.BlockCopy(sourceArray, sourceOffset, destinationArray, destinationOffset, count); Parameters sourceArray − The source array from which to copy bytes sourceOffset − The zero-based byte offset into the source array destinationArray − The destination array to ...

Read More

Mutation Testing in C#

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

Mutation testing in C# is a technique for evaluating the quality of your test suite by introducing small changes (mutations) to your source code and checking if your tests can detect these changes. If a test fails when the code is mutated, it indicates the test is effective at catching bugs. The primary purpose of mutation testing is to identify weaknesses in your test suite and improve test coverage quality beyond simple line coverage metrics. How Mutation Testing Works Mutation testing follows a systematic process to evaluate test effectiveness − Mutation Testing ...

Read More

How to create custom attributes in C#?

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

Custom attributes in C# allow you to store declarative information about program elements (classes, methods, properties, etc.) that can be retrieved at runtime using reflection. They provide metadata that doesn't affect program execution but can be used for documentation, validation, or configuration purposes. Syntax Following is the basic syntax for creating a custom attribute − [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] public class CustomAttribute : System.Attribute { // constructors and properties } Following is the syntax for applying the custom attribute − [CustomAttribute(parameters)] public class MyClass { // class ...

Read More

Date format validation using C# Regex

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

Date format validation in C# ensures that user input matches the expected date format before processing. The most reliable approach is using the DateTime.TryParseExact method, which validates both the format and the actual date values. For more complex pattern matching, Regular Expressions (Regex) can also be used. Syntax Following is the syntax for DateTime.TryParseExact method − bool DateTime.TryParseExact(string s, string format, IFormatProvider provider, DateTimeStyles style, out DateTime result) Following is the syntax for Regex date validation − Regex regex = new Regex(@"pattern"); bool isMatch = regex.IsMatch(dateString); ...

Read More

C# Program to convert integer array to string array

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

Converting an integer array to a string array is a common task in C# programming. The most efficient approach is using the Array.ConvertAll() method, which applies a conversion function to each element in the source array and returns a new array of the target type. Syntax Following is the syntax for Array.ConvertAll() method − string[] result = Array.ConvertAll(sourceArray, converter); Parameters sourceArray − The source integer array to convert converter − A lambda expression or method that converts each element Return Value Returns a new string ...

Read More

Priority Queues with C#

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

A priority queue is a data structure that stores elements with associated priority values. It is an extension of a regular queue where elements are served based on their priority rather than their insertion order. When you remove an item from a priority queue, the element with the highest priority is removed first. If two elements have the same priority, they are typically served in the order they were inserted. Syntax Following is the basic syntax for creating a priority queue class − public class MyPriorityQueue where T : IComparable { private ...

Read More

C# program to merge two sorted arrays into one

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

Merging two sorted arrays in C# involves combining the elements of both arrays into a single array while maintaining the sorted order. This is a fundamental operation used in algorithms like merge sort and when combining datasets. Approaches to Merge Sorted Arrays There are two main approaches to merge sorted arrays − Simple Concatenation: Append all elements from both arrays and then sort the result. Merge Algorithm: Compare elements from both arrays and merge them in sorted order without additional sorting. Using Simple Concatenation The simplest approach is to ...

Read More

Clear a list in C#

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

To clear a list in C#, you use the Clear() method which removes all elements from the list. This method is part of the List class and provides an efficient way to empty a list without recreating it. Syntax Following is the syntax for the Clear()

Read More

C# Program to remove a node at the end of the Linked List

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

In C#, you can remove the last node from a LinkedList using the RemoveLast() method. This method removes and returns the last node in the linked list, making it an efficient way to delete the tail element. Syntax Following is the syntax for removing the last node from a LinkedList − linkedList.RemoveLast(); The RemoveLast() method removes the last node and has no return value. If the list is empty, it throws an InvalidOperationException. How It Works The LinkedList class maintains references to both the first and last nodes. When RemoveLast() is called, ...

Read More
Showing 71–80 of 1,421 articles
« Prev 1 6 7 8 9 10 143 Next »
Advertisements