- 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 34486 Articles for Programming
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
305 Views
HashtableHashtable class represents a collection of key-and-value pairs that are organized based on the hash code of the key. It uses the key to access the elements in the collection.Some of the commonly used methods in Hashtable class are −Sr.No.Method & Description1public virtual void Add(object key, object value);Adds an element with the specified key and value into the Hashtable.2public virtual void Clear();Removes all elements from the Hashtable.3public virtual bool ContainsKey(object key);Determines whether the Hashtable contains a specific key.4public virtual bool ContainsValue(object value);Determines whether the Hashtable contains a specific value.The following is an example showing the usage of Hashtable class in ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
502 Views
The DateTime class in C# is used to represent date and time in C#.The following are some of the properties of DateTime in C# −Sr.NoProperty & Description1DateGets the Date component2DayGets the day of the month3HourGets the hour of the month4MinuteGets the minute of the date5MonthGets the month of the dateLet us see an example to compare date in C#.To compare dates in C#, you need to first set two dates to be compared using the DateTime object. We will use the DateTime class in C# −Date 1DateTime date1 = new DateTime(2018, 07, 20); Console.WriteLine("Date 1 : {0}", date1);Date 2DateTime date2 ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
3K+ Views
The Main method states what the class does when executed and instantiates other objects and variables.A main method is static since it is available to run when the C# program starts. It is the entry point of the program and runs without even creating an instance of the class.The following shows how to add a Main() method with static −Example Live Demousing System; namespace Demo { class HelloWorld { static void Main(string[] args) { Console.WriteLine("Bingo!"); Console.ReadKey(); } } }OutputBingo!As you can see in ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
67 Views
To declare an array in C#, you can use the following syntax −datatype[ ] Name_of_array;Here, datatype is used to specify the type of elements in the array.[ ] specifies the size of the array.Name_of_array specifies the name of the array.The following is an example −double[ ] balance;Let us see an example in which an array is declared and values are added to it −Example Live Demousing System; namespace ArrayApplication { class MyArray { static void Main(string[] args) { int [ ] n = new int[10]; /* n is an array of 10 ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
537 Views
In C++ the scope resolution operator i.e. :: is used for global variables, whereas in C# it is related to namespaces.If you have a type that share an identifier in different namespace, then to identify them use the scope resolution operator.For example, to reference System.Console class, use the global namespace alias with the scope resolution operator −global::System.ConsoleLet us see an example −Example Live Demousing myAlias = System.Collections; namespace Program { class Demo { static void Main() { myAlias::Hashtable h = new myAlias::Hashtable(); h.Add("M", "1"); ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
4K+ Views
The RemoveAt() method in C# is used to remove an element in a list at a position you set.Firstly, set elements in the list −var subjects = new List(); subjects.Add("Physics"); subjects.Add("Chemistry"); subjects.Add("Biology"); subjects.Add("Science");To remove an element, set the index from where you want to eliminate the element. The following is to remove an element from the 3rd position −subjects.RemoveAt(2);Let us see the complete code −Example Live Demousing System; using System.Collections.Generic; public class Demo { public static void Main(string[] args) { var subjects = new List(); subjects.Add("Physics"); subjects.Add("Chemistry"); ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
4K+ Views
To assign reference to a variable, use the ref keyword. A reference parameter is a reference to a memory location of a variable. When you pass parameters by reference, unlike value parameters, a new storage location is not created for these parameters. Declare the reference parameters using the ref keyword.Let us see an example −Here, we are swapping two values using the ref keyword −Example Live Demousing System; namespace Demo { class Program { public void swap(ref int x, ref int y) { int temp; temp = ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
537 Views
Set stack with Push operation to add elements to the Stack −Stack st = new Stack(); st.Push('A'); st.Push('M'); st.Push('G'); st.Push('W');To Pop elements from the stack, use Pop() method −st.Pop();st.Pop();The following is an example to implement a stack with Push and Pop operations −Example Live Demousing System; using System.Collections; namespace CollectionsApplication { class Program { static void Main(string[] args) { Stack st = new Stack(); st.Push('A'); st.Push('M'); st.Push('G'); st.Push('W'); Console.WriteLine("Current ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
78 Views
All arrays consist of contiguous memory locations. The lowest address corresponds to the first element and the highest address to the last element.Firstly, declare an array −int[] rank;But declaring an array does not initialize the array in the memory. When the array variable is initialized, you can assign values to the array.Array is a reference type, so you need to use the new keyword to create an instance of the array. For example, int[] rank = new int[5]; You can assign values to an array at the time of declaration −int[] rank = { 1, 2, 3, 4, 5};With that, ... Read More