Arjun Thakur

Arjun Thakur

749 Articles Published

Articles by Arjun Thakur

Page 13 of 75

Differences between C and C#

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 2K+ Views

C is a general-purpose, high-level programming language originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was first implemented on the DEC PDP-11 computer in 1972. C# is a simple, modern, general-purpose, object-oriented programming language developed by Microsoft within its .NET initiative led by Anders Hejlsberg. It was designed to combine the power of C++ with the simplicity of Visual Basic. While both languages share the letter "C" in their names, they represent different programming paradigms and approaches. Here are the key differences between C and C#. ...

Read More

How to convert a Decimal to Octal using C#?

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 471 Views

To convert a decimal number to its octal equivalent in C#, we use the division method where we repeatedly divide the decimal number by 8 and collect the remainders. The octal number system uses base 8, meaning it only uses digits 0-7. How It Works The conversion process involves dividing the decimal number by 8 repeatedly and storing the remainders in reverse order. Each remainder represents a digit in the octal representation. Decimal to Octal Conversion Process 18 ÷ 8 = ...

Read More

Convert.ToUInt16 Method in C#

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 305 Views

The Convert.ToUInt16 method in C# converts a specified value to a 16-bit unsigned integer (ushort). This method can convert various data types including strings, integers, doubles, and other numeric types to a ushort value ranging from 0 to 65, 535. Syntax Following are the common overloads of the Convert.ToUInt16 method − public static ushort ToUInt16(string value); public static ushort ToUInt16(int value); public static ushort ToUInt16(double value); public static ushort ToUInt16(bool value); Parameters value − The value to convert to a 16-bit unsigned integer. Can be a string representation of a number, numeric ...

Read More

C# program to find Union of two or more Lists

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 1K+ Views

The Union operation in C# combines multiple lists while removing duplicate elements. The Union() method from LINQ returns distinct elements from both collections, preserving the order of first occurrence. Syntax Following is the syntax for using the Union() method − var result = list1.Union(list2); For multiple lists, chain the Union operations − var result = list1.Union(list2).Union(list3); Using Union() Method with Two Lists The Union()

Read More

How to capture null reference exception in C#?

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 434 Views

A NullReferenceException occurs when you attempt to access a member (method, property, or field) of a null object reference. This is one of the most common runtime exceptions in C#. What Causes NullReferenceException? The exception is thrown when you try to access members of an object that has not been initialized or has been set to null − string str = null; int length = str.Length; // Throws NullReferenceException Using Null Checks The most straightforward way to prevent NullReferenceException is to check for null before accessing object members − using System; ...

Read More

C# All method

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 3K+ Views

The All() method in C# is a LINQ extension method that checks whether all elements in a collection satisfy a given condition. It returns a bool value − true if all elements meet the condition, or false if even one element fails the condition. The method is available for any IEnumerable collection and is commonly used with arrays, lists, and other collections for validation and filtering operations. Syntax Following is the syntax for the All() method − bool result = collection.All(predicate); Parameters predicate − A lambda expression or delegate that ...

Read More

Comparison between C# and .NET Framework

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 710 Views

C# is a programming language, while the .NET Framework is a comprehensive software development platform created by Microsoft. Understanding the relationship between these two is fundamental for .NET developers. The .NET Framework provides the Common Language Runtime (CLR), which serves as the execution environment for .NET applications. It also includes an extensive Base Class Library (BCL) that offers pre-built functionality for common programming tasks. What is C#? C# is an object-oriented programming language that runs on the .NET Framework. It was designed specifically for the .NET platform and compiles to Intermediate Language (IL) code, which the CLR ...

Read More

How to print a BinaryTriangle using C#?

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 641 Views

A binary triangle is a pattern formed using alternating 0s and 1s arranged in a triangular shape. Each row contains an increasing number of digits, and the pattern alternates between 0 and 1 for each position across all rows. How It Works The binary triangle is created using nested loops where the outer loop controls the number of rows, and the inner loop prints the alternating 0s and 1s for each row. A toggle variable switches between 0 and 1 to create the alternating pattern − Binary Triangle Pattern 1 ...

Read More

Union Method in C#

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 978 Views

The Union method in C# is a LINQ extension method that returns the unique elements from both collections. It combines two sequences and automatically removes duplicate values, ensuring each element appears only once in the result. Syntax Following is the syntax for the Union method − public static IEnumerable Union( this IEnumerable first, IEnumerable second ) Parameters first − The first sequence to merge. second − The second sequence to merge. Return Value Returns an IEnumerable containing ...

Read More

Why is f required while declaring floats in C#?

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 890 Views

The f suffix is required when declaring float literals in C# because without it, the compiler treats decimal numbers as double by default. The f suffix explicitly tells the compiler that the literal should be treated as a float type. Why the 'f' Suffix is Needed In C#, numeric literals with decimal points are interpreted as double precision floating-point numbers by default. Since double has higher precision than float, implicit conversion from double to float is not allowed because it could result in data loss. Literal Type Assignment ...

Read More
Showing 121–130 of 749 articles
« Prev 1 11 12 13 14 15 75 Next »
Advertisements