karthikeya Boyini

karthikeya Boyini

1,420 Articles Published

Articles by karthikeya Boyini

Page 28 of 142

How to remove items from a list in C#?

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

In C#, there are several ways to remove items from a List. The most commonly used methods are Remove(), RemoveAt(), RemoveAll(), and Clear(). Each method serves different purposes depending on whether you want to remove by value, by index, by condition, or all items. Syntax Following are the common syntaxes for removing items from a list − // Remove by value list.Remove(item); // Remove by index list.RemoveAt(index); // Remove all items matching a condition list.RemoveAll(predicate); // Remove all items list.Clear(); Using Remove() Method The Remove() method removes the first occurrence ...

Read More

C# program to print all sublists of a list

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

A sublist (or subsequence) of a string contains characters from the original string in the same order, but not necessarily consecutive. For example, from the string "xyz", possible sublists include "x", "xy", "xz", "y", "yz", "z", and "xyz". This program generates all possible sublists of a given string by building them incrementally using nested loops and dynamic list operations. How the Algorithm Works The algorithm processes each character of the input string and creates new sublists by combining existing sublists with the current character. It maintains a list that grows with each iteration, containing all possible sublists ...

Read More

How to print the contents of array horizontally using C#?

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

Printing array contents horizontally in C# means displaying all elements in a single line, separated by spaces or other delimiters. This is useful for creating formatted output where elements appear side by side rather than vertically. When you print an array using a regular loop with Console.WriteLine(), each element appears on a new line. To display elements horizontally, C# provides several approaches. Syntax Using string.Join() method − string.Join(separator, array) Using Console.Write() in a loop − for (int i = 0; i < array.Length; i++) { Console.Write(array[i] + ...

Read More

Constructors in C#

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

A constructor in C# is a special method that gets invoked automatically when an object is created. The constructor has the same name as the class and is used to initialize the object's state. Constructors do not have a return type, not even void. Syntax Following is the basic syntax for declaring a constructor − public class ClassName { public ClassName() { // constructor body } } Types of Constructors C# supports several types of constructors − Default ...

Read More

Lambda Expressions in C#

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

A lambda expression in C# is an anonymous function that provides a concise way to write inline functions. Lambda expressions use the => operator, read as "goes to", which separates the input parameters from the expression body. Lambda expressions are commonly used with LINQ methods, event handlers, and delegates to create short, readable code without defining separate methods. Syntax Following is the basic syntax for lambda expressions − (input-parameters) => expression For single parameter, parentheses are optional − x => x * 2 For multiple statements, use curly braces ...

Read More

C# Program to remove whitespaces in a string

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

In C#, there are several ways to remove whitespaces from a string. You can remove all spaces, only leading and trailing spaces, or all types of whitespace characters including tabs and newlines. Using String.Replace() Method The Replace()

Read More

Major features of C# programming

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

C# is a modern, general-purpose, object-oriented programming language developed by Microsoft. C# is designed for Common Language Infrastructure (CLI), which consists of the executable code and runtime environment that allows the use of various high-level languages on different computer platforms and architectures. C# combines the power of C++ with the simplicity of Visual Basic, making it an ideal choice for developing a wide range of applications from web services to desktop applications. Key Features of C# Major C# Features Core Language ...

Read More

Represent Int32 as a Binary String in C#

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

To represent an Int32 as a binary string in C#, use the Convert.ToString() method with base 2 as the second parameter. This method converts the integer's binary representation into a readable string format. 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 integer to binary string − Convert.ToString(value, 2) Parameters value − The integer value to convert to binary representation 2 − The base for binary number system ...

Read More

C# Round-trip ("R") Format Specifier

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

The round-trip ("R") format specifier in C# ensures that a numeric value converted to a string can be parsed back into the same exact numeric value without any precision loss. This format specifier is supported for Single, Double, and BigInteger types. The "R" specifier is particularly useful when you need to serialize floating-point numbers to strings and then deserialize them back while maintaining perfect accuracy. Syntax Following is the syntax for using the round-trip format specifier − value.ToString("R") value.ToString("R", CultureInfo.InvariantCulture) How It Works The round-trip format specifier automatically determines the minimum number ...

Read More

Differences between C++ and C#

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

C++ is a statically typed, compiled, general-purpose, case-sensitive programming language that supports procedural, object-oriented, and generic programming paradigms. It is regarded as a middle-level language because it combines both high-level and low-level language features. C# is a simple, modern, general-purpose, object-oriented programming language developed by Microsoft within its .NET initiative, led by Anders Hejlsberg. Both languages share some similarities but differ significantly in design philosophy and implementation. Key Differences Between C++ and C# Memory Management C++ uses manual memory management where developers must explicitly allocate and deallocate memory using new and delete operators. C# features automatic ...

Read More
Showing 271–280 of 1,420 articles
« Prev 1 26 27 28 29 30 142 Next »
Advertisements