George John has Published 1167 Articles

How to control for loop using break and continue statements in C#?

George John

George John

Updated on 20-Jun-2020 16:05:10

133 Views

Break statement terminates the loop. To use it in a for loop, you can get input from user everytime and display the output when user enters a negative number. The output gets displayed then and exited using the break statement −for(i=1; i

What are the methods and properties of the Thread class in C#?

George John

George John

Updated on 20-Jun-2020 15:31:04

294 Views

Threads are lightweight processes. One common example of use of thread is implementation of concurrent programming by modern operating systems.The following are some of the properties of the Thread class −Sr.No.Property & Description1CurrentContextGets the current context in which the thread is executing.2CurrentCultureGets or sets the culture for the current thread.3CurrentPrincipleGets ... Read More

How to calculate Power of a number using recursion in C#?

George John

George John

Updated on 20-Jun-2020 15:26:30

981 Views

To calculate power of a number using recursion, try the following code.Here, if the power is not equal to 0, then the function call occurs which is eventually recursion −if (p!=0) {    return (n * power(n, p - 1)); }Above, n is the number itself and the power reduces ... Read More

What does the interface ICollection do in C#

George John

George John

Updated on 20-Jun-2020 15:22:31

2K+ Views

The ICollection interface in C# defines the size, enumerators, and synchronization methods for all nongeneric collections. It is the base interface for classes in the System.Collections namespace.The following are the properties of ICollection interface −Sr.No.Property Name & Description1CountThe number of elements in the ICollection2SyncRootGets an object that useful to synchronize ... Read More

How to display numbers in the form of Triangle using C#?

George John

George John

Updated on 20-Jun-2020 15:20:37

174 Views

To display numbers in the form of Triangle, firstly consider a two dimensional array.int[, ] a = new int[5, 5];For a triangle, you need to consider spaces as shown below −1 1 1 1 2 1 1 3 3 1Then loop through to set the triangle with 1s on the ... Read More

How to declare a two-dimensional array in C#

George John

George John

Updated on 20-Jun-2020 15:14:51

633 Views

A 2-dimensional array is a list of one-dimensional arrays. Declare it like the two dimensional array shown below −int [, ] aTwo-dimensional arrays may be initialized by specifying bracketed values for each row.int [, ] a = new int [4, 4] { {0, 1, 2, 3} , {4, 5, 6, ... Read More

Transform the element along with x-axis using CSS

George John

George John

Updated on 20-Jun-2020 14:47:05

261 Views

Use the translateX(n) method to transform the element along with x-axis.Let us see the syntaxtranslateX(n)Here, n is a length representing the abscissa of the translating vector.Let us see an examplediv {    width: 50px;    height: 50px;    background-color: black; } .trans {    transform: translateX(20px);    background-color: orange; }

static keyword in C#

George John

George John

Updated on 20-Jun-2020 14:44:40

3K+ Views

We can define class members as static using the static keyword. When we declare a member of a class as static, it means no matter how many objects of the class are created, there is only one copy of the static member.The keyword static implies that only one instance of ... Read More

How to check if a C# list is empty?

George John

George John

Updated on 20-Jun-2020 14:34:01

2K+ Views

Use the Any method to find whether the list is empty or not.Set the list −var subjects = new List(); subjects.Add("Maths"); subjects.Add("Java"); subjects.Add("English"); subjects.Add("Science"); subjects.Add("Physics"); subjects.Add("Chemistry");Now set the following condition to check whether the list is empty or not −bool isEmpty = !subjects.Any(); if(isEmpty) {       Console.WriteLine("Empty");   ... Read More

What types of loops are supported in C#?

George John

George John

Updated on 20-Jun-2020 14:22:16

96 Views

A loop statement allows us to execute a statement or a group of statements multiple times. The following are the loops supported in C# −Sr.NoLoop Type & Description1while loopIt repeats a statement or a group of statements while a given condition is true. It tests the condition before executing the ... Read More

Advertisements