Use Copy Method of Array Class in C#

Arjun Thakur
Updated on 23-Jun-2020 12:35:11

384 Views

As the name suggests the Array.Copy() method in C# is used to copy elements of one array to another array.The following is the syntax.Array.Copy(src, dest, length);Heresrc = array to be copieddest = destination arraylength = how many elements to copyThe following is an example showing the usage of Copy(,,) method of array class in C#.Example Live Demousing System; class Program {    static void Main() {       int[] arrSource = new int[4];       arrSource[0] = 99;       arrSource[1] = 66;       arrSource[2] = 111;       arrSource[3] = 33;       int[] arrTarget = new int[4];       Array.Copy(arrSource, arrTarget, 4);       Console.WriteLine("Destination Array ...");       foreach (int value in arrTarget) {          Console.WriteLine(value);       }    } }OutputDestination Array ... 99 66 111 33

Set Horizontal Alignment of an Element with JavaScript

Monica Mona
Updated on 23-Jun-2020 12:34:52

372 Views

To align the element horizontally, use the cssFloat property.ExampleYou can try to run the following code to set the horizontal alignment of an element with JavaScript −Live Demo                 This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text.             Align Horizontally                function display() {             document.getElementById("myID").style.cssFloat = "right";          }          

Set Minimum Number of Lines at Bottom of Page with JavaScript

Srinivas Gorla
Updated on 23-Jun-2020 12:33:48

122 Views

Use the orphans property in JavaScript to set the minimum number of lines for an element that should be left at the bottom of a page when a page break occurs inside an element with JavaScript.You can return the orphans property like this −var res = object.style.orphansSet the orphans property like this −object.style.orphans = 'number|initial|inherit'The following are the property values shown above −number − Specify the minimum number of visible lines.Initial − Set property to its defaultInherit − Inherits property from the parent element

Use the Directory Class in C#

Ankith Reddy
Updated on 23-Jun-2020 12:33:42

491 Views

The Directory class in C# is used to manipulate the directory structure. It has methods to create, move, remove directories.The following are some of the methods of the Directory class.Sr.No.Method & Description1CreateDirectory(String)Creates all directories and subdirectories in the specified path2Delete(String)Deletes an empty directory3Exists(String)Whether the given path refers to an existing directory4GetCreationTime(String)Gets the creation date and time of a directory.5GetCurrentDirectory()Gets the current working directory6GetFiles(String)Let us learn about the usage of GetFiles() method in Directory class. It displays all the files in the specified directory.Exampleusing System; using System.IO; class Program {    static void Main() {       // Get all ... Read More

Sort an ArrayList in C#

Samual Sam
Updated on 23-Jun-2020 12:32:40

2K+ Views

To sort an ArrayList in C#, use the Sort() method.The following is the ArrayList.ArrayList arr = new ArrayList(); arr.Add(32); arr.Add(12); arr.Add(55); arr.Add(8); arr.Add(13);Now the Sort() method is used to sort the ArrayList.arr.Sort();You can try to run the following code to sort an ArrayList in C#.Example Live Demousing System; using System.Collections; namespace Demo {    class Program {       static void Main(string[] args) {          ArrayList arr = new ArrayList();          arr.Add(32);          arr.Add(12);          arr.Add(55);          arr.Add(8);          arr.Add(13);     ... Read More

Set Page Break Behavior Before an Element with JavaScript

Nancy Den
Updated on 23-Jun-2020 12:32:23

558 Views

Use the pageBreakBefore property in JavaScript to set the page-break behavior before an element. Use the always property to insert a page break before an element.Note − The changes would be visible while printing or viewing the print preview.ExampleYou can try to run the following code to return the page-break behavior before an element with JavaScript −           Heading 1       This is demo text.       This is demo text.       This if footer text.       Set page-break                      function display() {             document.getElementById("myFooter").style.pageBreakBefore = "always";          }          

Set Left Position of Positioned Element with JavaScript

Rishi Raj
Updated on 23-Jun-2020 12:31:43

1K+ Views

Use the left property to set the left position of a positioned element, such as a button.ExampleYou can try to run the following code to set the left position of a positioned element with JavaScript −Live Demo                    #myID {             position: absolute;          }                     Heading 1       This is Demo Text.       Change Left Position                function display() {             document.getElementById("myID").style.left = "150px";          }          

Base and Derived Classes in C#

Chandu yadav
Updated on 23-Jun-2020 12:29:37

287 Views

A class can be derived from more than one class or interface, which means that it can inherit data and functions from multiple base classes or interfaces.For example, Vehicle Base class with the following Derived Classes.Truck Bus MotobikeThe derived class inherits the base class member variables and member methods.In the same way, the derived class for Shape class can be Rectangle as in the following example.Example Live Demousing System; namespace Program {    class Shape {       public void setWidth(int w) {          width = w;       }       public void setHeight(int ... Read More

What Are Booleans Types in C#

Arjun Thakur
Updated on 23-Jun-2020 12:28:29

182 Views

For the Boolean type, the bool keyword is used and is an alias of System.Boolean.It is used to declare variables to store the Boolean values, true and false.Let us see an example to learn how to use bool in C#.Exampleusing System; public class Demo {    static void Main() {       bool val = true;       int d = DateTime.Now.DayOfYear;       val = (d % 2 == 0);       if (val) {          Console.WriteLine("days: even number");       } else {          Console.WriteLine("days:odd number");       }    } }

Create or Reset Counters with JavaScript

karthikeya Boyini
Updated on 23-Jun-2020 12:25:14

887 Views

To create counters, use the counterReset property in JavaScript. You can try to run the following code to create or reset one or more counters with JavaScript −ExampleLive Demo                    h2:before {             counter-increment: section;             content: counter(section) " Quiz ";          }                     Quizzes       Change the counterIncrement       Ruby       Java       PHP       Perl       Reset Counter                function display() {             document.body.style.counterReset = "section";          }          

Advertisements