Enumerate Files Method in C#

George John
Updated on 22-Jun-2020 15:01:48

435 Views

EnumerateFile() method is used in C# to get all the files. Use AllDirectories property to recurse through directories −Directory.EnumerateFiles(@"D:\NEW", "*.*", SearchOption.AllDirectories)To get the list of files in a directory, use the SearchOptions.AllDirectories in C# as shown above.Let us see how −Exampleusing System; using System.IO; namespace Demo {    class Program {       static void Main(string[] args) {          foreach (string allFiles is Directory.EnumerateFiles(@"D:\NEW","*.*",SearchOption.AllDirectories)) {             Console.WriteLine(allFiles);          }       }    } }OutputThe following is the output −D:\NEW\my.txt D:\NEW\amit.html D:\NEW\tutorials\java\a.java

The Fibonacci Sequence in JavaScript

karthikeya Boyini
Updated on 22-Jun-2020 15:00:49

522 Views

Fibonacci numbers are the numbers such that every number in the series after the first two is the sum of the two preceding ones. The series starts with 1, 1. Example −1, 1, 2, 3, 5, 8, 13, 21, 34, ….We can write a program to generate nth as follows −functionfibNaive(n) {    if (n

Function Generic Type in C#

Ankith Reddy
Updated on 22-Jun-2020 15:00:01

920 Views

The Func generic type store anonymous methods and is a parameterized type.In the below example, we have 4 func type instance −The first type receives int and returns stringFunc one = (p) => string.Format("{0}", p);The second type receives bool & long and returns stringFunc two = (q, p) =>string.Format("{0} and {1}", q, p);The third type receives bool & int and returns stringFunc three = (q, p) => string.Format("{0} and {1}", q, p);The fourth type receives decimal and returns stringFunc four = (p) =>string.Format("{0}", p);Let us see how to display them −Example Live Demousing System; using System.IO; namespace Demo {   ... Read More

System Calls in Unix and Windows

David Meador
Updated on 22-Jun-2020 14:59:06

27K+ Views

The interface between a process and an operating system is provided by system calls. In general, system calls are available as assembly language instructions. They are also included in the manuals used by the assembly level programmers.Unix System CallsSystem calls in Unix are used for file system control, process control, interprocess communication etc. Access to the Unix kernel is only available through these system calls. Generally, system calls are similar to function calls, the only difference is that they remove the control from the user process.There are around 80 system calls in the Unix interface currently. Details about some of ... Read More

Solaris OS Structure

Ricky Barnes
Updated on 22-Jun-2020 14:57:48

4K+ Views

Solaris is a Unix based operating system that was developed by Sun Microsystems and after its acquisition by Oracle, it is known as Oracle Solaris. It is known for its scalability and its innovative features such as DTrace, ZFS, Time Slider etc. Solaris is a microkernel design and it is not possible to create a monolithic Solaris kernel.A diagram demonstrating the structure of the Solaris operating system is as follows −The different components in the Solaris operating system structure are −HardwareThis includes the physical components of the computer system such as monitor, keyboard, data storage etc.I/O BufferI/O devices are very ... Read More

Transform Element Using 16 Values of Matrix with CSS3

George John
Updated on 22-Jun-2020 14:57:42

234 Views

Use the matrix3d(n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n) method to transform the element using 16 values of matrix.Let us see the syntaxmatrix3d(a1, b1, c1, d1, a2, b2, c2, d2, a3, b3, c3, d3, a4, b4, c4, d4)Here, a1 b1 c1 d1 a2 b2 c2 d2 a3 b3 c3 d3 d4 are numbers showing the linear transformationa4 b4 c4 are numbers describing the translation to apply.

Manipulate Decimals with Numeric Operators in C#

Samual Sam
Updated on 22-Jun-2020 14:56:09

246 Views

With C#, you can manipulate decimals with operators such as _+, - *, etc.Let us see how to subtract decimal values.Firstly, set two decimal values −decimal d1 = 9.5M; decimal d2 = 4.2M;Now to subtract the two values −d1 = d1 - d2;The following is the code −Example Live Demousing System; using System.Linq; class Demo {    static void Main() {       decimal d1 = 9.5M;       decimal d2 = 4.2M;       d1 = d1 + d2;       Console.WriteLine("Addition of Decimals: "+d1);       d1 = d1 - d2;       Console.WriteLine("Subtraction of Decimals: "+d1);    } }OutputAddition of Decimals: 13.7 Subtraction of Decimals: 9.5

C# Program to Display Temporary File Names

karthikeya Boyini
Updated on 22-Jun-2020 14:55:40

242 Views

The GetTempPath() method in C# displays temporary file names −Path.GetTempPath();Get the names in a variable and display −string tempFile = Path.GetTempPath();The following is the code −Example Live Demousing System; using System.IO; class Demo {    static void Main() {       string tempFile = Path.GetTempPath();       Console.WriteLine(tempFile);    } }Output/tmp/

Randomize String in C#

Arjun Thakur
Updated on 22-Jun-2020 14:54:50

2K+ Views

To randomize string, firstly use Random class −Random r = new Random();Now, use the Next() method with OrderBy() −string random = new string(str.ToCharArray().OrderBy(s => (r.Next(2) % 2) == 0).ToArray());Here is the compete code that displays randomize string −Example Live Demousing System; using System.IO; using System.Linq; class Demo {    static void Main() {       const string str = "electronics";       Random r = new Random();       string random = new string(str.ToCharArray().OrderBy(s => (r.Next(2) % 2) == 0).ToArray());       Console.WriteLine("String = {0}", str);       Console.WriteLine("Random String = {0}",random);       Console.Read();    } }OutputString = electronics Random String = lericsecton

C# Program to Generate Random Lowercase Letter

Ankith Reddy
Updated on 22-Jun-2020 14:54:23

2K+ Views

Firstly, set Random class −Random random = new Random();Set a range under the Next() method. This displays a letter between 0 and 26.int a = random.Next(0, 26);Here is the complete code −Example Live Demousing System; using System.IO; using System.Linq; class Demo {    static void Main() {       Random random = new Random();       // random lowercase letter       int a = random.Next(0, 26);       char ch = (char)('a' + a);       Console.WriteLine(ch);    } }Outputt

Advertisements