Jagged Array in C#

Samual Sam
Published on 08-Aug-2018 17:35:56
A Jagged array is an array of arrays. You can declare a jagged array named points of type int as −int [][] points;Let us now see how to initialize it −int[][] points = new int[][]{new int[]{10, 5}, new int[]{30, 40}, new int[]{70, 80}, new int[]{ 60, 70 }};Access the jagged ... Read More

How to declare a tuple in C#?

Chandu yadav
Published on 08-Aug-2018 17:37:16
To declare a tuple the following is the format wherein we have a tuple with int and string items −Tuple<int, string> tuple = new Tuple<int, string>(20, "Tom");Now, check for first item in the tuple, which is an integer −if (tuple.Item1 == 99) {    Console.WriteLine(tuple.Item1); }Now check for second item ... Read More

How to declare a delegate in C#?

karthikeya Boyini
Published on 08-Aug-2018 17:25:57
A delegate in C# is a reference to the method. A delegate is a reference type variable that holds the reference to a method. The reference can be changed at runtime.Delegates are especially used for implementing events and the call-back methods. All delegates are implicitly derived from the System.Delegate class.Let ... Read More

Quantifiers in C#

Arjun Thakur
Published on 08-Aug-2018 17:24:42
Quantifiers specify how many instances of the previous element (which can be a character, a group, or a character class) must be present in the input string for a match to occur.Let us see an example −The * Quantifies would match the previous element zero or more times, for example: ... Read More

Iterator Functions in C#

Samual Sam
Published on 08-Aug-2018 17:17:22
An iterator method performs a custom iteration over a collection. It uses the yield return statement and returns each element one at a time. The iterator remembers the current location and in the next iteration the next element is returned.The following is an example −Example Live Demousing System; using System.Collections.Generic; using ... Read More

Stack and Queue in C#

Ankith Reddy
Published on 08-Aug-2018 17:03:53
StackStack class represents a last-in, first out collection of object. It is used when you need a last-in, first-out access of items.The following is the property of Stack class −Count− Gets the number of elements in the stack.The following are the methods of Stack class −Sr.No.Method & Description1public virtual void ... Read More

Push vs pop in stack class in C#

karthikeya Boyini
Published on 08-Aug-2018 17:02:25
Stack class represents a last-in, first out collection of object. It is used when you need a last-in, first-out access of items.The following is the property of Stack class −Count − Gets the number of elements in the stack.Push OperationAdd elements in the stack using the Push operation −Stack st ... Read More

How to write single-line comments in C#?

Samual Sam
Published on 08-Aug-2018 16:55:47
If you want to add a comment that restricts itself to a single line, then use the single-line comments −// variable int i = 20;The following is a sample C# program showing how to add single-line comments −Example Live Demousing System; namespace Demo {    class Program {     ... Read More

Ternary Operator in C#

karthikeya Boyini
Published on 08-Aug-2018 16:49:51
Ternary operator is a Conditional operator in C#. It takes three arguments and evaluates a Boolean expression.For example −b = (a == 1) ? 20 : 30;Above, if the first operand evaluates to true (1), the second operand is evaluated. If the first operand evaluates to false (0), the third ... Read More

Threads in C#

Samual Sam
Published on 08-Aug-2018 16:44:20
A thread is defined as the execution path of a program. Each thread defines a unique flow of control. If your application involves complicated and time-consuming operations, then it is often helpful to set different execution paths or threads, with each thread performing a particular job.The life cycle of a ... Read More
Advertisements