Usage of onfocusin Event in JavaScript

Manikanth Mani
Updated on 23-Jun-2020 09:06:49

179 Views

The onfocusin event triggers when an element is to get focus. You can try to run the following code to learn how to implement onfocusin event in JavaScript −Example           Write below:                      function newFunc(x) {             x.style.background = "blue";          }          

Usage of oninput Event in JavaScript

Sai Nath
Updated on 23-Jun-2020 09:06:13

363 Views

When a value is added in an input box, then the oninput event occurs. You can try to run the following code to learn how to implement oninput event in JavaScript −Example           Write below:                            function inputFunc() {             var a = document.getElementById("newInput").value;             document.write("Typed: " + a);          }          

Represent Int32 as a String in C#

Samual Sam
Updated on 23-Jun-2020 09:06:04

295 Views

Int32 represents a 32-bit signed integer. To represent it as a string, use the ToString() method.Firstly, declare and initialize an Int32 variable.int val = 1023;Now, represent it as a string.val.ToString()Let us see the complete example.Example Live Demousing System; class Demo {    static void Main() {       int val = 1023;       Console.Write("Integer converted to string = "+val.ToString());    } }OutputInteger converted to string = 1023

C# Console WindowWidth Property

karthikeya Boyini
Updated on 23-Jun-2020 09:05:38

409 Views

The WindowWidth property gets or sets the width of the console window.Declare a variable.int width;Now, get the width of the current window.width = Console.WindowWidth;The following is the complete example.Example Live Demousing System; using System.Numerics; using System.Globalization; class Demo {    static void Main() {       int width;       int height;       width = Console.WindowWidth;       height = Console.WindowHeight;       Console.WriteLine("Current window width = "+width);       Console.WriteLine("Current window height = "+height);    } }OutputCurrent window width = 0 Current window height = 0

Convert ChangeType Method in C#

Chandu yadav
Updated on 23-Jun-2020 09:05:00

3K+ Views

The ChangeType() method returns an object of the specified type and whose value is equivalent to the specified object.Let’s say we have a double type.double val = -3.456Now, use the ChangeType method to change the type to integer.num = (int)Convert.ChangeType(val, TypeCode.Int32);Let us see the complete example.Example Live Demousing System; public class Demo {    public static void Main() {       double val = -3.456;       int num = (int)Convert.ChangeType(val, TypeCode.Int32);       Console.WriteLine("{0} converted to an Int32: {1}", val, num);    } }Output-3.456 converted to an Int32: -3

Convert toByte Method in C#

Arjun Thakur
Updated on 23-Jun-2020 09:04:35

1K+ Views

The Convert.ToByte method is used to convert a specified value to an 8-bit unsigned integer.Let’s say we have a char variable.Char charVal = ‘a’;Now, convert it to an 8-bit unsigned integer.byte byteVal = Convert.ToByte(charVal);Let us see another example now.Example Live Demousing System; public class Demo {    public static void Main() {       char[] charVal = { 'p', 'q', 'r', 's' };       foreach (char c in charVal) {          byte byteVal = Convert.ToByte(c);          Console.WriteLine("{0} is converted to = {1}", c, byteVal);       }    } }Outputp is converted to = 112 q is converted to = 113 r is converted to = 114 s is converted to = 115

Convert ToBoolean Method in C#

Samual Sam
Updated on 23-Jun-2020 09:04:09

2K+ Views

The Convert.ToBoolean method is used to convert a specified value to an equivalent Boolean value.The following is our double type.double doubleNum = 329.34;To convert it to Boolean, use the Convert.ToBoolean() method.bool boolNum; boolNum = System.Convert.ToBoolean(doubleNum);Let us see another example.Example Live Demousing System; public class Demo {    public static void Main() {       double doubleNum = 3.4;       bool boolNum;       // Double to bool       boolNum = System.Convert.ToBoolean(doubleNum);       System.Console.WriteLine("{0} as a Boolean = {1}.", doubleNum, boolNum);    } }Output3.4 as a Boolean = True.

C# LINQ Last Method

karthikeya Boyini
Updated on 23-Jun-2020 09:03:47

1K+ Views

Get the last element from a sequence using the Linq Last() method.The following is our array.int[] val = { 10, 20, 30, 40 };Now, get the last element.val.AsQueryable().Last();Example Live Demousing System; using System.Collections.Generic; using System.Linq; class Demo {    static void Main() {       int[] val = { 10, 20, 30, 40 };       // getting last element       int last_num = val.AsQueryable().Last();       Console.WriteLine("Last element: "+last_num);    } }OutputLast element: 40

Convert ToUInt64 Method in C#

Ankith Reddy
Updated on 23-Jun-2020 09:03:26

182 Views

Use the Convert.ToUInt64() method to convert a specified value to a 64-bit unsigned integer.The following is our char.char ch = 'a';Now, let’s convert it to a 64-bit unsigned integer.ulong res; res = Convert.ToUInt64(ch);Here is the complete example.Example Live Demousing System; public class Demo {    public static void Main() {       char ch = 'a';       ulong res;       res = Convert.ToUInt64(ch);       Console.WriteLine("Converted char value '{0}' to {1}", ch, res);    } }OutputConverted char value 'a' to 97

The 0 Custom Format Specifier in C#

karthikeya Boyini
Updated on 23-Jun-2020 09:02:56

2K+ Views

The “0” custom specifier is a zero placeholder.If the value to be formatted has a digit in the position where the zero appears in the format string, the the digit is copied to the resultant string. However, if this doesn’t happen, then a zero appears.Here is our double variable.double d; d = 292;Now, by setting the following, you can easily make zero appear in the format string.d.ToString("00000")Example Live Demousing System; using System.Globalization; class Demo {    static void Main() {       double d;       d = 292;       Console.WriteLine(d.ToString("00000"));       Console.WriteLine(String.Format("{0:00000}", d));   ... Read More

Advertisements