Chandu yadav

Chandu yadav

810 Articles Published

Articles by Chandu yadav

Page 13 of 81

Large Fibonacci Numbers in C#

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 551 Views

To display large Fibonacci numbers in C#, we need to handle numbers that exceed the range of standard integer types. The Fibonacci sequence grows exponentially, so after just 40-50 terms, the values become too large for int or even long data types. For truly large Fibonacci numbers, we use the BigInteger class from System.Numerics, which can handle arbitrarily large integers without overflow. Syntax Following is the basic syntax for generating Fibonacci numbers − int val1 = 0, val2 = 1, val3; for (int i = 2; i < n; i++) { val3 ...

Read More

IS vs AS Operators in C#

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 1K+ Views

The is and as operators in C# are used for type checking and type conversion. The is operator checks if an object is compatible with a given type and returns a boolean value, while the as operator attempts to convert an object to a specified type and returns null if the conversion fails. Syntax Following is the syntax for the is operator − expr is type Following is the syntax for the as operator − expr as type Where expr is the expression to test and type is the target ...

Read More

What is the IsReadOnly property of Hashtable class in C#?

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 170 Views

The IsReadOnly property of the Hashtable class in C# returns a boolean value indicating whether the Hashtable is read-only. When a Hashtable is read-only, you cannot add, remove, or modify its elements. By default, all Hashtable instances created using the standard constructor are not read-only, meaning they allow modifications. However, you can create read-only wrappers using specific methods. Syntax Following is the syntax for accessing the IsReadOnly property − bool isReadOnly = hashtable.IsReadOnly; Return Value The IsReadOnly property returns − true if the Hashtable is read-only false if the Hashtable ...

Read More

Where to use #region directive in C#?

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 5K+ Views

The #region directive in C# is a preprocessor directive that allows you to specify a block of code that can be collapsed or expanded in code editors like Visual Studio. This feature improves code organization and readability by grouping related code sections together. The #region directive must always be paired with a corresponding #endregion directive to mark the end of the collapsible block. Syntax Following is the syntax for using the #region directive − #region Region Name or Description // Code block that can be collapsed #endregion Basic Usage of #region Example ...

Read More

Convert.ToInt16 Method in C#

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 881 Views

The Convert.ToInt16 method in C# converts a specified value to a 16-bit signed integer (short). This method accepts various data types including double, string, boolean, and other numeric types, and returns a short value ranging from -32, 768 to 32, 767. When converting from floating-point numbers, the method performs rounding to the nearest integer. If the value is exactly halfway between two integers, it rounds to the even number. Syntax Following are the common overloads of the Convert.ToInt16 method − public static short ToInt16(double value); public static short ToInt16(string value); public static short ToInt16(bool value); ...

Read More

How to declare a tuple in C#?

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 539 Views

A tuple in C# is a data structure that can hold multiple values of different types. Tuples are useful when you need to return multiple values from a method or group related data together without creating a separate class. C# provides two main ways to declare tuples: the classic Tuple class and the newer value tuples introduced in C# 7.0 with cleaner syntax. Syntax Classic tuple syntax − Tuple tuple = new Tuple(value1, value2); Value tuple syntax (C# 7.0+) − (int, string) tuple = (value1, value2); // or with named elements ...

Read More

How to find and display the Multiplication Table in C#?

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 1K+ Views

A multiplication table displays the product of a number with a sequence of other numbers. In C#, you can generate and display multiplication tables using loops and formatted output. This is useful for educational applications, mathematical calculations, or creating reference tables. Syntax The basic structure for creating a multiplication table uses a loop with formatted output − while (counter

Read More

C# program to find Union of two or more Dictionaries

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 793 Views

The union of two or more dictionaries combines all unique keys from the dictionaries. In C#, you can find the union using HashSet and the UnionWith() method to merge dictionary keys, or use LINQ methods to combine both keys and values. Syntax Following is the syntax for finding union of dictionary keys using HashSet − HashSet unionKeys = new HashSet(dict1.Keys); unionKeys.UnionWith(dict2.Keys); Following is the syntax for merging dictionary values using LINQ − var unionDict = dict1.Union(dict2).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); Using HashSet for Key Union The most straightforward ...

Read More

Represent Int64 as a Binary string in C#

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 2K+ Views

To represent Int64 as a binary string in C#, use the Convert.ToString() method with base 2 as the second parameter. Int64 represents a 64-bit signed integer that can hold values from -9, 223, 372, 036, 854, 775, 808 to 9, 223, 372, 036, 854, 775, 807. Syntax Following is the syntax for converting Int64 to binary string − Convert.ToString(longValue, 2) Parameters longValue − The Int64 value to convert 2 − The base for binary representation Return Value Returns a string representation of the Int64 value in binary format (base ...

Read More

C# program to concat two or more Lists

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 299 Views

In C#, you can concatenate multiple List objects using the Concat() method from LINQ. This method creates a new sequence that contains all elements from the original lists in order without modifying the original lists. Syntax Following is the syntax for concatenating lists using the Concat() method − var result = list1.Concat(list2); For multiple lists, you can chain the Concat() calls − var result = list1.Concat(list2).Concat(list3); Using Concat() to Merge Two Lists Example using System; using System.Collections.Generic; using System.Linq; public class Demo { ...

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