karthikeya Boyini

karthikeya Boyini

1,421 Articles Published

Articles by karthikeya Boyini

Page 22 of 143

Does declaring an array create an array in C#?

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

Declaring an array in C# does not create the actual array object in memory. Array declaration only creates a reference variable that can point to an array object. The array must be explicitly initialized using the new keyword to allocate memory and create the array instance. Array Declaration vs Array Creation Understanding the difference between declaration and creation is crucial for working with arrays in C# − Array Declaration vs Creation Declaration Only int[] arr; • Creates reference variable • No memory ...

Read More

What is a managed code in C#?

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

Managed code in C# is code whose execution is managed by the Common Language Runtime (CLR). The CLR provides automatic memory management, type safety, exception handling, and garbage collection. When you write C# code, it gets compiled into Intermediate Language (IL) code, which is then executed by the CLR. Unlike unmanaged code (such as C/C++), managed code runs within the .NET runtime environment, which handles low-level operations automatically. This makes development safer and more efficient by reducing common programming errors like memory leaks and buffer overflows. How Managed Code Works The execution process of managed code follows ...

Read More

Local Inner Class in C#

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

A nested class in C# is a class declared inside another enclosing class. The nested class is a member of its outer class and can access the outer class's private members, while the outer class cannot directly access the nested class's members without creating an instance. Nested classes provide better organization and encapsulation by grouping related functionality together. They are particularly useful when a class is only meaningful within the context of another class. Syntax Following is the syntax for declaring a nested class − class OuterClass { // outer class ...

Read More

How to iterate two Lists or Arrays with one foreach statement in C#?

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

When working with multiple collections in C#, you often need to iterate through them simultaneously. The Zip() method from LINQ provides an elegant solution to combine two arrays or lists and iterate them with a single foreach statement. Syntax Following is the syntax for using the Zip() method to combine two collections − var result = collection1.Zip(collection2, (item1, item2) => new { Prop1 = item1, Prop2 = item2 }); The lambda expression defines how to combine elements from both collections into a new anonymous object. Using Zip() with Arrays The Zip() method ...

Read More

What is the use of 'new' keyword in C#?

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

The new keyword in C# serves multiple important purposes. It is primarily used to create new instances of classes, allocate memory for arrays, and hide inherited members from base classes. Syntax Following is the syntax for creating object instances using new − ClassName objectName = new ClassName(); Following is the syntax for creating arrays using new − dataType[] arrayName = new dataType[size]; Following is the syntax for hiding base class members using new − public new void MethodName() { // hides the base class method ...

Read More

Checked vs Unchecked Exceptions in C#

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

The checked and unchecked keywords in C# control whether arithmetic operations throw exceptions when overflow occurs. By default, C# ignores arithmetic overflow in most contexts, but you can explicitly enable or disable overflow checking using these keywords. In a checked context, arithmetic overflow throws an OverflowException. In an unchecked context, overflow is ignored and the result wraps around to the valid range. Syntax Following is the syntax for checked operations − int result = checked(expression); checked { // multiple statements } Following is the syntax for unchecked operations − ...

Read More

C# Program to remove duplicate characters from String

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

Removing duplicate characters from a string is a common programming task in C#. There are several approaches to achieve this, with HashSet being one of the most efficient methods due to its automatic handling of unique elements. Using HashSet to Remove Duplicates The HashSet collection automatically maintains unique elements, making it perfect for removing duplicate characters from a string − using System; using System.Linq; using System.Collections.Generic; class Program { static void Main(string[] args) { string myStr = "kkllmmnnoo"; Console.WriteLine("Initial String: ...

Read More

How to validate a string for a numeric representation using TryParse in C#

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

The TryParse method in C# is used to validate whether a string contains a valid numeric representation. It attempts to convert the string to a number and returns true if successful, or false if the conversion fails. This is safer than using Parse because it doesn't throw exceptions on invalid input. Syntax Following is the syntax for using TryParse − bool result = int.TryParse(stringValue, out int number); Parameters stringValue − The string to be parsed. out number − The output parameter that receives the parsed value if successful, or ...

Read More

How to get int value from enum in C#?

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

In C#, an enum (enumeration) is a value type that represents a group of named constants. By default, each enum value has an underlying integer value starting from 0. You can extract the integer value from an enum using type casting. Syntax Following is the syntax for casting an enum to int − int value = (int)EnumName.EnumValue; Following is the syntax for declaring an enum − public enum EnumName { Value1, Value2, Value3 } Using Default Integer Values By default, enum values are assigned integer values starting from 0 ...

Read More

How to convert Lower case to Upper Case using C#?

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

To convert lowercase to uppercase in C#, use the ToUpper() method. This method converts all lowercase characters in a string to their uppercase equivalents and returns a new string without modifying the original string. Syntax Following is the syntax for the ToUpper() method − string.ToUpper() string.ToUpper(CultureInfo) Parameters CultureInfo (optional) − Specifies the culture-specific formatting information. If not provided, the current culture is used. Return Value The ToUpper() method returns a new string with all lowercase characters converted to uppercase. The original string remains unchanged. Using ToUpper() Method ...

Read More
Showing 211–220 of 1,421 articles
« Prev 1 20 21 22 23 24 143 Next »
Advertisements