A Constructor in C# is invoked automatically when an object gets created. The constructor has the same name as that of the class, for example −public class Department { public Department () { Console.WriteLine("Default Constructor! "); } }The following is the code that shows the usage of default constructor in C#. The constructor invokes immediately when the object gets created.Department dept1 = new Department ();A default constructor is a constructor that has no argument, for example −Department () { }Let us see the complete example to learn how to work with default contructors.Example Live Demousing System; ... Read More
A delegate in C# is a reference to the method. A delegate is a reference type variable that holds the reference to a method. The reference can be changed at runtime.Delegates are especially used for implementing events and the call-back methods. All delegates are implicitly derived from the System.Delegate class.Let us see how to declare delegates in C#.delegate Let us see an example to learn how to work with Delegates in C#.Example Live Demousing System; using System.IO; namespace DelegateAppl { class PrintString { static FileStream fs; static StreamWriter sw; ... Read More
The Equality Operator ( ==) is the comparison operator and the Equals() method in C# is used to compare the content of a string.The Equals() method compares only content.Example Live Demousing System; namespace ComparisionExample { class Program { static void Main(string[] args) { string str = "hello"; string str2 = str; Console.WriteLine("Using Equality operator: {0}", str == str2); Console.WriteLine("Using equals() method: {0}", str.Equals(str2)); Console.ReadKey(); } } }OutputUsing Equality operator: True Using equals() method: ... Read More
To get the querystring of the href attribute of an area, use the search property. You can try to run the following code to search the querystring −Example var x = document.getElementById("myarea").search; document.write("Querystring: "+x);
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
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP