- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 34494 Articles for Programming
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
69 Views
Use the IsFixedSize property in C# to get a value indicating whether the SortedList has a fixed size.The following is an example showing SorteList with the usage of IsFixedSize property.Example Live Demousing System; using System.Collections; namespace Demo { class Program { static void Main(string[] args) { SortedList s = new SortedList(); s.Add("S1", "Maths"); s.Add("S2", "Science"); s.Add("S3", "English"); s.Add("S4", "Economics"); Console.WriteLine("IsFixedSize = " + s.IsFixedSize); } } }OutputIsFixedSize = FalseWe ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
12K+ Views
Using the DateTime nullable type, you can assign the null literal to the DateTime type.A nullable DateTime is specified using the following question mark syntax.DateTime?The following is the code to implement Nullable Datetime.Example Live Demousing System; class Program { static void Main() { DateTime? dt = null; DateFunc(dt); dt = DateTime.Now; DateFunc(dt); dt = null; Console.WriteLine(dt.GetValueOrDefault()); } static void DateFunc(DateTime? dt) { if (dt.HasValue) { Console.WriteLine(dt.Value); } else { Console.WriteLine(0); } } }Output0 9/17/2018 8:27:07 AM 1/1/0001 12:00:00 AM
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
1K+ Views
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 created. You can give instructions for superclass initialization in the member initialization list.Here you can see object is created for the inherited class.Example Live Demousing System; namespace Demo { class Rectangle { protected double length; protected double width; public Rectangle(double l, ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
3K+ Views
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 is an interface defining a single method GetEnumerator that returns an IEnumerator interface.This works for readonly access to a collection that implements that IEnumerable can be used with a foreach statement.The following shows the implementation of IEnumerable interface.Exampleclass Demo : IEnumerable, IEnumerator { // IEnumerable method GetEnumerator() IEnumerator ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
2K+ Views
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 secure numbers, you can try to run the following code.Example Live Demousing System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using System.Security.Cryptography; public class Demo { public static void Main(string[] args) { for (int i = 0; i
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
2K+ Views
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 int num1; public class Two { public int num2; } } class Demo { static void Main() { One a = new One(); a.num1++; One.Two ab = new One.Two(); ab.num2++; } ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
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 shown in the following code −Example Live Demousing System; using System.Collections; class Program { static void Main() { Hashtable h = new Hashtable(); h.Add(1, "India"); h.Add(2, "US"); h.Add(3, "UK"); h.Add(4, "Australia"); h.Add(5, "Netherland"); foreach (int k in h.Keys) { Console.WriteLine(k); } } }Output5 4 3 2 1
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
6K+ Views
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 3x3 size i.e 9 elements.Add both the matrices and print the third array that has the sum.for(i=0;i
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
56 Views
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 following is our example stating how to use the IsReadOnly property of BitArray class in C#.Example Live Demousing System; using System.Collections; namespace Demo { class Program { static void Main(string[] args) { BitArray ba1 = new BitArray(5); BitArray ba2 ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
556 Views
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 Exception("Number cannot be less than the divisor!"); else return (val1 % val2); }Above we have checked for two conditions i.e.If the second number is zero, an exception occurs.If the first number is less than the second number, an exception occurs.To return remainder of two numbers, the following is ... Read More