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));
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
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
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));
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
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
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.
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
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
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
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP