Default Constructor in C#

Samual Sam
Updated on 23-Jun-2020 09:25:13

350 Views

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

Delegates in C#

Chandu yadav
Updated on 23-Jun-2020 09:24:41

305 Views

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

Difference Between == and equals() Method in Java

karthikeya Boyini
Updated on 23-Jun-2020 09:23:20

7K+ Views

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

Search Query String in Href Attribute of an Area in JavaScript

Ramu Prasad
Updated on 23-Jun-2020 09:23:07

152 Views

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);          

Convert 0 to Number in JavaScript

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

112 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

651 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

571 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

132 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

Advertisements