C# BitConverter ToChar Method

AmitDiwan
Updated on 02-Dec-2019 12:07:51

200 Views

The BitConverter.ToChar() method in C# is used to returns a Unicode character converted from two bytes at a specified position in a byte array.Syntaxpublic static char ToChar (byte[] value, int begnIndex);Above, val is the byte array, whereas begnIndex is the beginning position within val.Example Live Demousing System; public class Demo {    public static void Main() {       byte[] arr = { 0, 20, 50, 65 };       Console.WriteLine("Array = {0} ",       BitConverter.ToString(arr));       for (int i = 1; i < arr.Length - 1; i = i + 2) {     ... Read More

Boolean GetHashCode Method in C# with Examples

AmitDiwan
Updated on 02-Dec-2019 11:25:31

163 Views

The Boolean.GetHashCode() method in C# is used to return the hash code for this instance.Syntaxpublic override int GetHashCode ();Example Live Demousing System; public class Demo {    public static void Main(String[] args){       string str = "JackSparrow!";       bool val = true;       char[] arr = { 'J', 'a'};       Console.WriteLine("String = "+str);       Console.WriteLine("String (after trim) = " + str.Trim(arr));       Console.WriteLine("String (Hashcode) = "+str.GetHashCode());       Console.WriteLine("Bool (Hashcode) = "+val.GetHashCode());    } }OutputString = JackSparrow! String (after trim) = ckSparrow! String (Hashcode) = -203134198 Bool (Hashcode) = 1Example Live Demousing System; public class Demo {    public static void ... Read More

What is POD in Perl

Mohd Mohtashim
Updated on 02-Dec-2019 10:53:16

694 Views

Pod is a simple-to-use markup language used for writing documentation for Perl, Perl programs, and Perl modules. There are various translators available for converting Pod to various formats like plain text, HTML, man pages, and more. Pod markup consists of three basic kinds of paragraphs −Ordinary Paragraph − You can use formatting codes in ordinary paragraphs, for bold, italic, code-style , hyperlinks, and more.Verbatim Paragraph − Verbatim paragraphs are usually used for presenting a codeblock or other text which does not require any special parsing or formatting, and which shouldn't be wrapped.Command Paragraph − A command paragraph is used for ... Read More

The kill Function in Perl

Mohd Mohtashim
Updated on 02-Dec-2019 10:51:53

994 Views

Perl kill('KILL', (Process List)) function can be used to terminate a pseudo-process by passing it the ID returned by fork().Note that using kill('KILL', (Process List)) on a pseudo-process() may typically cause memory leaks, because the thread that implements the pseudo-process does not get a chance to clean up its resources.You can use kill() function to send any other signal to target processes, for example following will send SIGINT to a process IDs 104 and 102 −#!/usr/bin/perl kill('INT', 104, 102); 1;

The Fork Function in Perl

Mohd Mohtashim
Updated on 02-Dec-2019 10:49:35

5K+ Views

Perl provides a fork() function that corresponds to the Unix system call of the same name. On most Unix-like platforms where the fork() system call is available, Perl's fork() simply calls it. On some platforms such as Windows where the fork() system call is not available, Perl can be built to emulate fork() at the interpreter level.The fork() function is used to clone a current process. This call create a new process running the same program at the same point. It returns the child pid to the parent process, 0 to the child process, or under if the fork is ... Read More

The System Function in Perl

Mohd Mohtashim
Updated on 02-Dec-2019 10:44:06

15K+ Views

You can use system() Perl function to execute any Unix command, whose output will go to the output of the perl script. By default, it is the screen, i.e., STDOUT, but you can redirect it to any file by using redirection operator > −#!/usr/bin/perl system( "ls -l") 1;When above code is executed, it lists down all the files and directories available in the current directory −drwxr-xr-x 3 root root 4096 Sep 14 06:46 9-14 drwxr-xr-x 4 root root 4096 Sep 13 07:54 android -rw-r--r-- 1 root root 574 Sep 17 15:16 index.htm drwxr-xr-x 3 544 401 4096 Jul 6 16:49 MIME-Lite-3.01 ... Read More

Backtick Operator in Perl

Mohd Mohtashim
Updated on 02-Dec-2019 10:38:35

253 Views

This simplest way of executing any Unix command in Perl Program is by using backstick operator. You simply put your command inside the backstick operator, which will result in execution of the command and returns its result which can be stored as follows −#!/usr/bin/perl @files = `ls -l`; foreach $file (@files) {    print $file; } 1;When the above code is executed, it lists down all the files and directories available in the current directory −drwxr-xr-x 3 root root 4096 Sep 14 06:46 9-14 drwxr-xr-x 4 root root 4096 Sep 13 07:54 android -rw-r--r-- 1 root root 574 Sep 17 ... Read More

What are Perl Modules

Mohd Mohtashim
Updated on 02-Dec-2019 10:37:10

271 Views

A Perl module is a reusable package defined in a library file whose name is the same as the name of the package with a .pm as extension.A Perl module file called Foo.pm might contain statements like this.#!/usr/bin/perl package Foo; sub bar {    print "Hello $_[0]" } sub blat {    print "World $_[0]" } 1;Few important points about Perl modulesThe functions require and use will load a module.Both use the list of search paths in @INC to find the module.Both functions require and use call the eval function to process the code.The 1; at the bottom causes eval to evaluate to TRUE (and thus not ... Read More

Begin and End Blocks in Perl

Mohd Mohtashim
Updated on 02-Dec-2019 10:32:20

2K+ Views

You may define any number of code blocks named BEGIN and END in Perl programs, which act as constructors and destructors respectively.BEGIN { ... } END { ... } BEGIN { ... } END { ... }Every BEGIN block is executed after the perl script is loaded and compiled but before any other statement is executed.Every END block is executed just before the perl interpreter exits.The BEGIN and END blocks are particularly useful when creating Perl modules.Following example shows its usage −Example Live Demo#!/usr/bin/perl package Foo; print "Begin and Block Demo"; BEGIN {    print "This is BEGIN Block" } END { ... Read More

What Are Packages in Perl

Mohd Mohtashim
Updated on 02-Dec-2019 10:30:06

382 Views

The package statement in Perl switches the current naming context to a specified namespace (symbol table). Thus −A package is a collection of code which lives in its own namespace.A namespace is a named collection of unique variable names (also called a symbol table).Namespaces prevent variable name collisions between packages.Packages enable the construction of modules which, when used, won't clobber variables and functions outside of the modules's own namespace.The package stays in effect until either another package statement is invoked, or until the end of the current block or file.You can explicitly refer to variables within a package using the :: package ... Read More

Advertisements