Add and Remove Methods in Chash Lists

karthikeya Boyini
Updated on 23-Jun-2020 12:17:39

1K+ Views

The List is a collection in C# and is a generic collection. The add and remove methods are used in C# lists for adding and removing elements.Let us see how to use Add() method in C#.Example Live Demousing System; using System.Collections.Generic; class Program {    static void Main() {       List sports = new List();       sports.Add("Football");       sports.Add("Tennis");       sports.Add("Soccer");       foreach (string s in sports) {          Console.WriteLine(s);       }    } }OutputFootball Tennis SoccerLet us see how to use Remove() method in C#.Example Live ... Read More

Set Column Width and Count with JavaScript

Vikyath Ram
Updated on 23-Jun-2020 12:16:55

761 Views

To set the column width and column count in a single declaration, use the JavaScript columns property.ExampleYou can try to run the following code to set column width and column count with JavaScript −                    #myID {             column-count: 4;             column-rule: 4px solid yellow;          }                     Click below to change the column count to 2 and minimum size       Change Column count and ... Read More

Possible Hash Array Initialization Syntaxes

Arjun Thakur
Updated on 23-Jun-2020 12:16:46

122 Views

Array can be initialized in more than one ways in C#. Let us see some example.Method OneUsing size of array.int [] marks = new int[5] { 99, 98, 92, 97, 95};Method TwoBy omitting the size.int [] marks = new int[] { 99, 98, 92, 97, 95};Method ThreeInitializing at the time of declaration.int [] marks = { 99, 98, 92, 97, 95};Let us see one of the ways to initialize arrays in C#.Example Live Demousing System; namespace Demo {    class MyArray {       static void Main(string[] args) {          int [] n = new int[10]; /* ... Read More

Set Length of Item Relative to Others with JavaScript

Abhinaya
Updated on 23-Jun-2020 12:16:12

128 Views

Use the flex property in JavaScript to set the length of the item relative to the rest. You can try to run the following code to implement flex property with JavaScript −Example                    #box {             border: 1px solid #000000;             width: 300px;             height: 400px;             display: flex;          }                              DIV1          DIV2          DIV3             Set                function display() {             var a = document.getElementById("box");             var b = a.getElementsByTagName("DIV");             var j ;             for (j = 0; j < b.length; j++) {                b[j].style.flex = "1";             }          }          

Difference between window.location.href, window.location.replace, and window.location.assign in JavaScript

Arjun Thakur
Updated on 23-Jun-2020 12:14:47

650 Views

The window object includes the location object in JavaScript. It includes the following properties −window.location.hrefIt returns the URL of the current page.Example           Click below to get the complete URL of the page.       URL                function display() {             var res = location.href;             document.write(res);          }           window.location.replaceIt is used to replace the current document.Example           Replace current document                function display() {             location.replace("https://www.qries.com")          }           window.location.assignIf you want to load a new document, use JavaScript assign.Example           Open new document                function display() {             location.assign("https://www.qries.com")          }          

Find Maximum Between 2 Numbers Using C#

George John
Updated on 23-Jun-2020 12:12:53

1K+ Views

Firstly, declare and initialize two numbers.int num1 = 50; int num2 = 90;With that, use if-else to find the maximum number.if (num1 > num2) {    maxNum = num1; } else {    maxNum = num2; }Above, we have set the maximum value to the variable maxNum and printed it later on.The following is the complete example to find maximum between 2 numbers in C#.Example Live Demousing System; namespace Demo {    class Program {       static void Main(string[] args) {          int num1 = 50;          int num2 = 90;     ... Read More

Create a Thread in C#

Chandu yadav
Updated on 23-Jun-2020 12:11:59

693 Views

Threads are lightweight processes. A thread is defined as the execution path of a program. Threads are created by extending the Thread class. The extended Thread class then calls the Start() method to begin the child thread execution.Example of Thread: One common example of use of thread is implementation of concurrent programming by modern operating systems. Use of threads saves wastage of CPU cycle and increase efficiency of an application.The following is an example showing how to create a thread.Example Live Demousing System; using System.Threading; namespace Demo {    class Program {       public static void ThreadFunc() {   ... Read More

Create Tuple with String and Int Items in C#

karthikeya Boyini
Updated on 23-Jun-2020 12:11:10

427 Views

Firstly, set two items in the tuple.Tuple tuple = new Tuple(20, "Tom");Now check for first item in the tuple, which is an integer.if (tuple.Item1 == 20) {    Console.WriteLine(tuple.Item1); }Now check for second item in the tuple, which is a string −if (tuple.Item2 == "Tom") {    Console.WriteLine(tuple.Item2); }The following is an example to create a tuple with string and int items.Example Live Demousing System; using System.Threading; namespace Demo {    class Program {       static void Main(string[] args) {          Tuple tuple = new Tuple(20, "Tom");          if (tuple.Item1 == 20) { ... Read More

Create an Infinite Loop in C#

Arjun Thakur
Updated on 23-Jun-2020 12:10:34

1K+ Views

An infinite loop is a loop that never terminates and repeats indefinitely.Let us see an example to create an infinite loop in C#.Exampleusing System; namespace Demo {    class Program {       static void Main(string[] args) {          for (int a = 0; a < 50; a--) {             Console.WriteLine("value : {0}", a);          }          Console.ReadLine();       }    } }Above, the loop executes until a < 50. The value of is set to 0 initially.int a = 0;The value of a decrements after each iteration since it is set to.a--;Therefore the value of a will never be above 50 and the condition a

Create Arrays Dynamically in C#

Samual Sam
Updated on 23-Jun-2020 12:10:04

5K+ Views

Dynamic arrays are growable arrays and have an advantage over static arrays. This is because the size of an array is fixed.To create arrays dynamically in C#, use the ArrayList collection. It represents ordered collection of an object that can be indexed individually. It also allows dynamic memory allocation, adding, searching and sorting items in the list.The following is an example showing how to create arrays in dynamically in C#.Example Live Demousing System; using System.Collections; namespace CollectionApplication {    class Program {       static void Main(string[] args) {          ArrayList al = new ArrayList();     ... Read More

Advertisements