Convert 0 to Number in JavaScript

karthikeya Boyini
Updated on 23-Jun-2020 09:22:27

123 Views

Use the Number() method in JavaScript to convert to Number. You can try to run the following code to learn how to convert 0 to Number in JavaScript −ExampleLive Demo           Convert 0 to Number                var myVal = 0;          document.write("Number: " + Number(myVal));          

Set Fixed Background Image with JavaScript DOM

Rishi Raj
Updated on 23-Jun-2020 09:21:58

670 Views

To set the background image to be fixed in JavaScript, use the backgroundAttachment property. It allows you to set an image that won’t scroll.ExampleYou can try to run the following code to learn how to work with backgroundAttachment property with JavaScript −Live Demo           Click to Set background       Demo Text       Demo Text       Demo Text       Demo Text       Demo Text       Demo Text       Demo Text       Demo Text       Demo Text     ... Read More

Different Methods to Find Prime Numbers in C#

George John
Updated on 23-Jun-2020 09:21:11

593 Views

The following are the two ways through which you can find a prime number in C#.Check Prime Number using for loop Live Demousing System; namespace Program {    class Demo {       public static void Main() {          int n =7;          int a;          a = 0;          for (int i = 1; i

Convert 1 to Boolean in JavaScript

Paul Richard
Updated on 23-Jun-2020 09:20:39

148 Views

You can try to run the following code to learn how to convert 1 to Boolean in JavaScript −ExampleLive Demo           Convert 1 to Boolean                var myVal = 1;          document.write("Boolean: " + Boolean(myVal));          

C# Enum GetName Method

karthikeya Boyini
Updated on 23-Jun-2020 09:19:43

2K+ Views

The GetName() method returns the names of the constants in the Enumeration.Here is the enum.enum Stock { Appliance, Clothing, Footwear };Now, get the names using the Enum.GetName() method. Just set the constant and retrieve the individual name.Enum.GetName(typeof(Stock), 1Let us see the example now.Example Live Demousing System; class Demo {    enum Stock { Appliance, Clothing, Footwear };    static void Main() {       Console.WriteLine("The value of second stock category = {0}", Enum.GetName(typeof(Stock), 1));       Console.WriteLine("The value of third stock category = {0}", Enum.GetName(typeof(Stock), 2));    } }OutputThe value of second stock category = Clothing The value of ... Read More

C# Enum GetNames Method

Chandu yadav
Updated on 23-Jun-2020 09:19:20

1K+ Views

The GetNames() returns the array of names of the constants in the Enumeration.The following is the enum.enum Stock { Watches, Books, Grocery };To get the array of names, use the GetNames() and loop through as shown below −foreach(string s in Enum.GetNames(typeof(Stock))) { }Let us see the complete example now.Example Live Demousing System; class Demo {    enum Stock { Watches, Books, Grocery };    static void Main() {       Console.WriteLine("The value of first stock category = {0}", Enum.GetName(typeof(Stock), 0));       Console.WriteLine("The value of second stock category = {0}", Enum.GetName(typeof(Stock), 1));       Console.WriteLine("The value of third ... Read More

Browser Window Resize Event in JavaScript

Nishtha Thakur
Updated on 23-Jun-2020 09:18:50

168 Views

Use window.outerWidth and window.outerHeight event in JavaScript to get the size of windows when the browser is resized.ExampleYou can try to run the following code to work with events to check the browser window size −                    function resizeFunction() {             var val = "Window Width=" + window.outerWidth + ", Window Height="             + window.outerHeight;             document.getElementById("test").innerHTML = val;          }                     Resize browser window and check the window (browser window)       height and width again.          

Get Type of Specified Enumeration in C#

Samual Sam
Updated on 23-Jun-2020 09:18:47

182 Views

Use the GetType() method to get the type of the enumeration.The enumeration.Enum[] values = { ConsoleColor.Blue, DayOfWeek.Sunday};Now to get the type, use the GetType() method.Type enumType = val.GetType();The following is an example that displays the type.Example Live Demousing System; public class Demo {    public static void Main() {       Enum[] values = { ConsoleColor.Blue, DayOfWeek.Sunday};       Console.WriteLine("{0, -5} {1, 10} {2, 10}", "Member", "Enumeration", "UnderlyingType");       foreach (var val in values)       Info(val);    }    static void Info(Enum val) {       Type enumType = val.GetType();       Type ... Read More

C# Enum GetValues Method

Arjun Thakur
Updated on 23-Jun-2020 09:18:16

2K+ Views

Get the array of the values of the constants in a specified enumeration.Here is our enum.enum Rank { Jack = 10, Tom = 19, Tim = 26 };Now, get all the values of the enum as an array and display using GetValues() method.foreach(int res in Enum.GetValues(typeof(Rank))) {    Console.WriteLine(res); }Let us see the entire example.Example Live Demousing System; public class Demo {    enum Rank { Jack = 10, Tom = 19, Tim = 26 };    public static void Main() {       Console.WriteLine("Here are the university rank of MCA Students College ABC:");       foreach(int res in ... Read More

Complex Numbers in C#

karthikeya Boyini
Updated on 23-Jun-2020 09:17:01

4K+ Views

To work WITH and display complex numbers in C#, you need to check for real and imaginary values.A complex number like 7+5i is formed up of two parts, a real part 7, and an imaginary part 5. Here, the imaginary part is the multiple of i.To display complete numbers, use the −public struct ComplexTo add both the complex numbers, you need to add the real and imaginary part −public static Complex operator +(Complex one, Complex two) {    return new Complex(one.real + two.real, one.imaginary + two.imaginary); }You can try to run the following code to work with complex numbers in ... Read More

Advertisements