Karthikeya Boyini has Published 2193 Articles

How do we use a break statement in while loop in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 15:08:57

244 Views

The break statement terminates the loop and transfers execution to the statement immediately following the loop.When the break statement is encountered inside a loop, the loop is immediately terminated and program control resumes at the next statement following the loop.Let us see an example to learn how to work with ... Read More

Extracting MAC address using C#

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 15:06:50

4K+ Views

A MAC address of a device is a media access control address. It is a unique identifier assigned to a network.The MAC address technology is used by many technologies such as Ethernet, Bluetooth, Fibre Channel, etc.Here, we will use the following method to check for all the network interfaces on ... Read More

How do you sort an array in C# in descending order?

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 14:46:40

5K+ Views

The following is the unsorted array.int[] list = {98, 23, 97, 36, 77};Now first use the Sort() method to sort the array.Array.Reverse(list);Use the Reverse() method that would eventually give you a sorted array in descending order.Array.Reverse(list);You can try to run the following code to to sort an array in descending ... Read More

How do we use multi-dimensional arrays in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 14:45:08

206 Views

C# allows multidimensional arrays. Multi-dimensional arrays are also called rectangular array. Declare a 2-dimensional array of strings as.string [, ] names;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 ... Read More

How do I sort a two-dimensional array in C#

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 14:41:25

2K+ Views

To sort a two-dimensional array in C#, in a nested for loop, add another for loop to check the following condition.Examplefor (int k = 0; k < j; k++) {    if (arr[i, k] > arr[i, k + 1]) {       int myTemp = arr[i, k];     ... Read More

How do you use ‘foreach’ statement for accessing array elements in C#

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 14:39:01

146 Views

To access Array elements in a foreach statement, use the numeric index.Let’s say the following is our code.Example Live Demousing System; namespace ArrayApplication {    class MyArray {       static void Main(string[] args) {          int [] n = new int[10]; /* n is an array ... Read More

How do we pass parameters by value in a C# method?

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 14:32:38

154 Views

This is the default mechanism for passing parameters to a method. In this mechanism, when a method is called, a new storage location is created for each value parameter.The values of the actual parameters are copied into them. Hence, the changes made to the parameter inside the method have no ... Read More

How to split a string into elements of a string array in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 14:25:16

1K+ Views

Set the string you want to split.string str = "Hello World!";Use the split() method to split the string into separate elements.string[] res = str.Split(' ');The following is the complete code to split a string into elements of a string array in C#.Example Live Demousing System; class Demo {    static void ... Read More

What to do with content that renders outside the element box with JavaScript?

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 13:35:09

246 Views

If the content renders outside the element box, use the overflow property to add a scroll. This will ease visitors in reading the entire content.ExampleYou can try to run the following code to learn how to work with overflow property in JavaScript −Live Demo           ... Read More

How to set the bottom margin of an element with JavaScript?

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 13:18:11

744 Views

Use the marginBottom property in JavaScript, to set the bottom margin.ExampleYou can try to run the following code to set the bottom margin of an element with JavaScript −Live Demo           This is demo text.       Set bottom margin                function display() {             document.getElementById("myID").style.marginBottom = "95px";          }          

Advertisements