Chandu yadav has Published 1163 Articles

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

Chandu yadav

Chandu yadav

Updated on 23-Jun-2020 09:56:43

79 Views

Gets an ICollection containing the keys in the Hashtable. It displays all the keys in the collection. In the below code, to get all the keys we have used a loop to loop through the collection.foreach (int k in h.Keys) {    Console.WriteLine(k); }The above displays all the keys as ... Read More

Decimal Functions in C#

Chandu yadav

Chandu yadav

Updated on 23-Jun-2020 09:44:15

188 Views

The following are some of the decimal functions in C#.Sr.No.Name & Description1Add (Decimal, Decimal)Adds two specified Decimal values.2Ceiling(Decimal)Returns the smallest integral value that is greater than or equal to the specified decimal number.3Compare (Decimal, Decimal)Compares two specified Decimal values.4CompareTo(Decimal)Compares this instance to a specified Decimal object and returns a comparison of their relative values.5CompareTo(Object)Compares this instance ... Read More

Equivalent of Java Super Keyword in C#

Chandu yadav

Chandu yadav

Updated on 23-Jun-2020 09:37:08

6K+ Views

For super keyword in Java, we have the base keyword in C#.Super keyword in Java refers immediate parent class instance. It is used to differentiate the members of superclass from the members of subclass, if they have same names. It is used to invoke the superclass constructor from subclass.C# base ... Read More

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

Chandu yadav

Chandu yadav

Updated on 23-Jun-2020 09:34:34

78 Views

The IsReadOnly property of Hashtable class is used to get a value indicating whether the Hashtable is read-only.Example Live Demousing System; using System.Collections; namespace Demo {    class Program {       static void Main(string[] args) {          Hashtable ht = new Hashtable();         ... Read More

C# Program to display the Factors of the Entered Number

Chandu yadav

Chandu yadav

Updated on 23-Jun-2020 09:28:42

240 Views

Firstly, let us enter the number.Console.WriteLine("Enter a Number"); n = int.Parse(Console.ReadLine());Now loop through and find the mod of the entered number with i = 1 that increments after every iteration. If its 0, then print it, since it would be our factor.for (i= 1; i

Delegates in C#

Chandu yadav

Chandu yadav

Updated on 23-Jun-2020 09:24:41

194 Views

A delegate in C# is a reference to the method. A delegate is a reference type variable that holds the reference to a method. The reference can be changed at runtime.Delegates are especially used for implementing events and the call-back methods. All delegates are implicitly derived from the System.Delegate class.Let ... Read More

C# Enum GetNames Method

Chandu yadav

Chandu yadav

Updated on 23-Jun-2020 09:19:20

816 Views

The GetNames() returns the array of names of the constants in the Enumeration.The following is the enum.enum Stock { Watches, Books, Grocery };To get the array of names, use the GetNames() and loop through as shown below −foreach(string s in Enum.GetNames(typeof(Stock))) { }Let us see the complete example now.Example Live Demousing ... Read More

C# Enum Format Method

Chandu yadav

Chandu yadav

Updated on 23-Jun-2020 09:11:16

575 Views

The Format method converts value of a specified enumerated type to its equivalent string representation. Here you can also set the format i.e. d for Decimal, x for HexaDecimal, etc.We have the following enumeration.enum Stock { PenDrive, Keyboard, Speakers };The default value gets assigned (initialize).PenDrive = 0 Keyboard = 1 ... Read More

Convert.ChangeType Method in C#

Chandu yadav

Chandu yadav

Updated on 23-Jun-2020 09:05:00

2K+ Views

The ChangeType() method returns an object of the specified type and whose value is equivalent to the specified object.Let’s say we have a double type.double val = -3.456Now, use the ChangeType method to change the type to integer.num = (int)Convert.ChangeType(val, TypeCode.Int32);Let us see the complete example.Example Live Demousing System; public class ... Read More

C# Linq Except Method

Chandu yadav

Chandu yadav

Updated on 23-Jun-2020 09:00:10

2K+ Views

Get the difference between two arrays using the Except() method.The following are the two arrays.int[] arr = { 9, 12, 15, 20, 35, 40, 55, 67, 88, 92 }; int[] arr2 = { 20, 35 };To get the difference, use Except() method that returns the first list, except the elements ... Read More

Advertisements