C# Interface Types

Ankith Reddy
Published on 17-Sep-2018 16:03:37
Interfaces define properties, methods, and events, which are the members of the interface.Interfaces contain only the declaration of the members.Some of the interface types in C# include.IEnumerable − Base interface for all generic collections.IList − A generic interface implemented by the arrays and the list type.IDictionary − A dictionary collection.IEnumerable ... Read More

C# Object Creation of Inherited Class

Samual Sam
Published on 17-Sep-2018 16:02:55
A class can be derived from more than one class or interface, which means that it can inherit data and functions from multiple base classes or interfaces.The derived class inherits the base class member variables and member methods. Therefore, the super class object should be created before the subclass is ... Read More

C# Nested Classes

Arjun Thakur
Published on 17-Sep-2018 15:59:09
A nested class is a class declared in another enclosing class. It is a member of its enclosing class and the members of an enclosing class have no access to members of a nested class.Let us see an example code snippet of nested classes in C#.Exampleclass One {    public ... Read More

C# program to generate secure random numbers

karthikeya Boyini
Published on 17-Sep-2018 15:59:12
For secure random numbers, use the RNGCryptoServiceProvider Class. It implements a cryptographic Random Number Generator.Using the same class, we have found some random values using the following −using (RNGCryptoServiceProvider crypto = new RNGCryptoServiceProvider()) {    byte[] val = new byte[6];    crypto.GetBytes(val);    randomvalue = BitConverter.ToInt32(val, 1); }To generate random ... Read More

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

Chandu yadav
Published on 17-Sep-2018 15:52:43
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

C# program to add two matrices

Samual Sam
Published on 17-Sep-2018 15:52:54
Firstly, set three arrays.int[, ] arr1 = new int[20, 20]; int[, ] arr2 = new int[20, 20]; int[, ] arr3 = new int[20, 20];Now users will enter values in both the matrices. We have to set the row and size columns as n=3, since we want a square matrix of ... Read More

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

George John
Published on 17-Sep-2018 15:44:34
The BitArray class is used when you need to store the bits but do not know the number of bits in advance.Using the IsReadOnly class, you can get a value indicating whether the BitArray is read-only or not. ReadOnly will not allow you to add new elements to the BitArray.The ... Read More

C# program to accept two integers and return the remainder

karthikeya Boyini
Published on 17-Sep-2018 15:44:29
Firstly, set the two numbers.int one = 250; int two = 200;Now pass those numbers to the following function.public int RemainderFunc(int val1, int val2) {    if (val2 == 0)    throw new Exception("Second number cannot be zero! Cannot divide by zero!");    if (val1 < val2)    throw new ... Read More

What is the Item property of ArrayList class in C#?

Ankith Reddy
Published on 17-Sep-2018 15:40:30
Use the Item property of ArrayList class to get or set the element at the specified index in the ArrayList.The Item property is an indexer so you can use it without adding the property name.In the below example, we have used it like the following statement −Console.WriteLine("Element {0} is \"{1}\"", ... Read More

C# program to remove n-th character from a string

Samual Sam
Published on 17-Sep-2018 15:40:25
To remove a character, use the remove() method and set the index from where you want to delete the character.Firstly, set the string.string str1 = "Amit"; Console.WriteLine("Original String: "+str1);To delete a character at position 4.StringBuilder strBuilder = new StringBuilder(str1); strBuilder.Remove(3, 1);You can try to run the following code to remove ... Read More
Advertisements