What are the prerequisites for learning C#?

Arjun Thakur
Updated on 21-Jun-2020 12:27:50

364 Views

To start learning C#, firstly you should have computer knowledge. With that, if you have a prior learning experience in C or C#, then it would be great.To start with C#, first install Visual Studio. The current version is Visual Studio 2017.If you want to avoid the hassles of installing a bulky Visual Studio IDE, then you can begin with Online Compilers. The top online compilers to run C# programs are −Coding groundDotNetFiddleBoth of the above are intelligent compilers. Just go there, type the C# code and run it. That’s it!

Deque interface in Java

Fendadis John
Updated on 21-Jun-2020 12:26:34

298 Views

java.util.Deque interface is a subtype of java.util.Queue interface which supports insertion and removal of elements at both ends.Interface Declarationpublic interface Deque extends QueueArrayDeque ClassThe java.util.ArrayDeque class provides resizable-array and implements the Deque interface. Following are the important points about Array Deques −Array deques have no capacity restrictions so they grow as necessary to support usage.They are not thread-safe; in the absence of external synchronization.They do not support concurrent access by multiple threads.Null elements are prohibited in the array deques.They are faster than Stack and LinkedList.This class and its iterator implement all of the optional methods of the Collection and Iterator ... Read More

Difference between ArrayList and CopyOnWriteArrayList in Java

Vikyath Ram
Updated on 21-Jun-2020 12:23:44

2K+ Views

Following are the notable differences between ArrayList and CopyOnWriteArrayList classes in Java. ArrayListCopyOnWriteArrayListSynchronizedArrayList is not synchronized.CopyOnWriteArrayList is synchronized.Thread SafeArrayList is not thread safe.CopyOnWriteArrayList is thread safe.Iterator typeArrayList iterator is fail-fast and ArrayList throws ConcurrentModificationException if concurrent modification happens during iteration.CopyOnWriteArrayList is fail-safe and it will never throw ConcurrentModificationException during iteration. The reason behind the it that CopyOnWriteArrayList creates a new arraylist every time it is modified.Remove OpearationArrayList iterator supports removal of element during iteration.CopyOnWriteArrayList.remove() method throws exception if elements are tried to be removed during iteration.PerformanceArrayList is faster.CopyOnWriteArrayList is slower than ArrayList.Since Java Version1.21.5Exampleimport java.util.Iterator; import java.util.concurrent.CopyOnWriteArrayList; public class Tester { ... Read More

What is the simplest multi-dimensional array in C#?

Chandu yadav
Updated on 21-Jun-2020 12:22:13

70 Views

The simplest multi-dimensional array in C# is a two-dimensional array. A 2-dimensional array can be thought of as a table, which has x number of rows and y number of columns.Multidimensional arrays may be initialized by specifying bracketed values for each row. The following array is with 4 rows and each row has 4 columns.int [, ] a = new int [4, 4] {    {0, 1, 2, 3} , /* initializers for row indexed by 0 */    {4, 5, 6, 7} , /* initializers for row indexed by 1 */    {8, 9, 10, 11} /* initializers for ... Read More

What are two-dimensional arrays in C#?

George John
Updated on 21-Jun-2020 12:20:25

193 Views

A 2-dimensional array is a list of one-dimensional arrays.Two-dimensional arrays may be initialized by specifying bracketed values for each row.int [,] a = new int [2,2] {    {0, 1} ,    {4, 5} };The following is an example showing how to work with two-dimensional arrays in C# −using System; namespace ArrayApplication {    class MyArray {       static void Main(string[] args) {          /* an array with 3 rows and 2 columns*/          int[,] a = new int[3, 2] {{0,0}, {1,2}, {2,4} };          int i, j;          /* output each array element's value */          for (i = 0; i < 3; i++) {             for (j = 0; j < 2; j++) {                Console.WriteLine("a[{0},{1}] = {2}", i, j, a[i,j]);             }          }          Console.ReadKey();       }    } }

Difference between HashMap and ConcurrentHashMap in Java

Arushi
Updated on 21-Jun-2020 12:18:12

4K+ Views

Following are the notable differences between HashMap and ConcurrentHashMap classes in Java. HashMapConcurrentHashMapSynchronizedHashMap is not synchronized.ConcurrentHashMap is synchronized.Thread SafeHashMap is not thread safe.ConcurrentHashMap is thread safe.Iterator typeHashMap iterator is fail-fast and ArrayList throws ConcurrentModificationException if concurrent modification happens during iteration.ConcurrentHashMap is fail-safe and it will never throw ConcurrentModificationException during iteration.Null valuesHashMap allows key and value to be null.ConcurrentHashMap does not allow null key/value. It will throw NullPointerException.PerformanceHashMap is faster.ConcurrentHashMap is slower than HashMap.Since Java Version1.21.5Exampleimport java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; public class Tester {    public static void main(String[] args) {       List arrayList = new ArrayList(); ... Read More

What are tokens in C#?

Samual Sam
Updated on 21-Jun-2020 12:17:27

1K+ Views

Token is the smallest element of a program. Let us learn about identifiers and keywords in C# that are tokens −KeywordsKeywords are reserved words predefined to the C# compiler. These keywords cannot be used as identifiers. However, if you want to use these keywords as identifiers, you may prefix the keyword with the @ character.The following are some of the reserved keywords in C# −abstractAsBaseboolBreakbytecasecatchcharcheckedclassConstcontinuedecimaldefaultdelegateDodoubleElseenumeventexplicitexternFalsefinallyFixedfloatforforeachgotoIfimplicitInin (generic modifier)intinterfaceinternalIslockLongnamespacenewnullobjectoperatoroutout (generic modifier)overrideparamsIdentifiersAn identifier is a name used to identify a class, variable, function, or any other user-defined item. The basic rules for naming classes in C# are as follows −A name must begin ... Read More

What is the octal equivalent of a decimal number in C#?

karthikeya Boyini
Updated on 21-Jun-2020 12:14:46

106 Views

To get the octal equivalent of a decimal in C# −Firstly, for the decimal value use a while loop and store the remainder in the array set for octal. Here we found the mod 8 of them in the array.After that, divide the number by 8 −while (dec != 0) {    oct[i] = dec % 8;    dec = dec / 8;    i++; }Let us see the complete code. Here, our decimal number is 12 −Exampleusing System; namespace Demo {    class Program {       static void Main(string[] args) {       ... Read More

What is Type safe in C#?

Samual Sam
Updated on 21-Jun-2020 12:13:47

1K+ Views

Type safe in C# wouldn’t allow an object to sneak into other object’s memory. Let us see an example to understand the concept of −Examplepublic class One {    public int Prop{ get; set;} } public class Two {    public int Prop{get;set;}    public int Prop1{get;set;} }Let’s say I have an object Class One −One ob = new One();Now you won’t be able to cast your object ob to the second class i.e. class Two. If you will cast it then a compile time error will arise because of the Type Safe feature in C#.

Transpose a matrix in C#

George John
Updated on 21-Jun-2020 12:11:32

2K+ Views

Transpose of a matrix flips the matrix over its diagonal and this brings the row elements on the column and column elements on the row.For example −Matrix before Transpose: 123 456 789 Matrix after Transpose: 147 258 369Let us see an example in C# to achieve transpose of a matrix −Exampleusing System; public class Demo {    public static void Main() {       int i, j, m, n;       int[, ] arr1 = new int[30, 30];       int[, ] arr2 = new int[30, 30];       Console.Write("Enter the number of ... Read More

Advertisements