- 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
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
87 Views
A jagged array is an array of arrays, and therefore its elements are reference types and are initialized to null.Let us see how to work with Jagged array −Declare a jagged array −int [][] marks;Now, let us initialize it, wherein marks is an arrays of 5 integers −int[][] marks = new int[][]{new int[]{ 40, 57 }, new int[]{ 34, 55 }, new int[]{ 23, 44 }, new int[]{ 56, 78 }, new int[]{ 66, 79 } };Let us now see the complete example of jagged arrays in C# and learn how to implement it −Example Live Demousing System; namespace MyApplication ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
1K+ Views
Set two arrays that you wish to merge −int[] arr1 = new int[5] { 5, 15, 25, 30, 47 }; int[] arr2 = new int[5] { 55, 60, 76, 83, 95 };Now take a third array that would merge both the above arrays −int[] merged = new int[10];The following is the code that merges two arrays into the third array in C# −Example Live Demousing System; using System.Collections.Generic; class Program { static void Main() { int i = 0; int j = 0; ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
1K+ Views
To get the difference between two lists, firstly set two lists in C# −// first list List < string > list1 = new List < string > (); list1.Add("A"); list1.Add("B"); list1.Add("C"); list1.Add("D"); // second list List < string > list2 = new List < string > (); list2.Add("C"); list2.Add("D"); foreach(string value in list2) { Console.WriteLine(value); }To get the difference, use IEnumerable and Except() as shown below. The difference is shown in the third list −IEnumerable < string > list3; list3 = list1.Except(list2);The following is the complete code −Example Live Demousing System; using System.Collections.Generic; using System.Linq; public class Demo ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
13K+ Views
Use the DateTime.TryParseExact method in C# for Date Format validation.They method converts the specified string representation of a date and time to its DateTime equivalent. It checks whether the entered date format is correct or not.Example Live Demousing System; using System.Globalization; namespace Demo { class Program { static void Main(string[] args) { DateTime d; bool chValidity = DateTime.TryParseExact( "08/14/2018", "MM/dd/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out d); Console.WriteLine(chValidity); } } }OutputTrue
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
289 Views
Java has SortedMap Interface, whereas an equivalent of it in C# is SortedList.SortedList collection in C# use a key as well as an index to access the items in a list.A sorted list is a combination of an array and a hash table. It contains a list of items that can be accessed using a key or an index. If you access items using an index, it is an ArrayList, and if you access items using a key, it is a Hashtable. The collection of items is always sorted by the key value.Let us see an example to work with ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
785 Views
Firstly, set a string array −string[] arr = new string[] { "Indian", "Moroccon", "American", };To sort the words in lexicographical order −var sort = from a in arr orderby a select a;Example Live DemoLet us see the complete code −using System; using System.Linq; class Program { static void Main() { string[] arr = new string[] { "Indian", "Moroccon", "American", }; var sort = from a in arr orderby a select a; foreach(string res in sort) { Console.WriteLine(res); } } }outputAmerican Indian Moroccon
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
335 Views
Declare an array and initialize −int[] arr = new int[] { 87, 23, 65, 29, 67 };To sort, use the Sort() method and CompareTo() to compare and display in decreasing order −Array.Sort < int > (arr, new Comparison < int > ((val1, val2) => val2.CompareTo(val1)));Let us see the complete code −Example Live Demousing System; using System.Collections.Generic; using System.Text; public class Demo { public static void Main(string[] args) { int[] arr = new int[] { 87, 23, 65, ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
531 Views
ReaderWriterLock synchronize access to a resource. A ReaderWriterLock has better throughput than a Monitor, which is one-at-a-time lock. This works for a situation when a resource is changed rarely. Let us see how to declare a ReaderWriter lock in C# − static ReaderWriterLock r = new ReaderWriterLock(); The following are the properties of a ReaderWriter lock in C# − Sr.No. Property & Description 1 IsReaderLockHeld Gets a value indicating whether the current thread holds a reader lock. 2 IsWriterLockHeld Gets a value indicating whether the current thread holds a Writer lock. ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
924 Views
Unit testing is a key for C# code since it can help in maintaining code in the development process. It lets you know about the problems in the development cycle. With Unit Testing, you can make the code reliable and reusable. One of the fundamental principles of adopting unit testing is to follow a TDD (Test Driven Development) approach where we have to write tests case first, and then write the simple code that will make the test pass For Unit testing, you need to work with Microsoft Testing tools, which is what we call MS Unit Test. To create ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
658 Views
The .NET Framework 4 introduced System.Collections.Concurrent namespace. The namespace has numerous collection classes. These classes are both thread-safe and scalable. Multiple threads can safely add or remove items from these collections, The following concurrent collection types use lightweight synchronization mechanisms: SpinLock, SpinWait, etc. These are new in .NET Framework 4. Let us see the concurrent collection in C# − Sr.No. Type & Description 1 BlockingCollection Bounding and blocking functionality for any type. 2 ConcurrentDictionary Thread-safe implementation of a dictionary of key-value pairs. 3 ConcurrentQueue Thread-safe implementation of a FIFO ... Read More