Chandu yadav has Published 1091 Articles

Equivalent of Java Super Keyword in C#

Chandu yadav

Chandu yadav

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

8K+ 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

134 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

375 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

295 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

1K+ 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

785 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

3K+ 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

3K+ 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

C# Linq Contains Method

Chandu yadav

Chandu yadav

Updated on 23-Jun-2020 08:58:04

3K+ Views

To check for an element in a string, use the Contains() method.The following is our string array.string[] arr = { "Java", "C++", "Python"};Now, use Contains() method to find a specific string in the string array.arr.AsQueryable().Contains(str);Let us see the complete example.Example Live Demousing System; using System.Linq; using System.Collections.Generic; class Demo {   ... Read More

Represent Int64 as a Hexadecimal String in C#

Chandu yadav

Chandu yadav

Updated on 23-Jun-2020 08:50:32

2K+ Views

To represent Int64 as a Binary string in C#, use the ToString() method and set the base as the ToString() method’s second parameter i.e.16 for Hexadecimal.Int64 represents a 64-bit signed integer.Firstly, set an Int64 variable.long val = 947645;Now, convert it to a hex string by including 16 as the second ... Read More

Advertisements