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
CompositionUnder Composition, if the parent object is deleted, then the child object also loses its status. Composition is a special type of Aggregation and gives a part-of relationship.For example, A Car has an engine. If the car is destroyed, the engine is destroyed as well.public class Engine { . . . } public class Car { Engine eng = new Engine(); ....... }AggregationAggregation is a directional relation between objects in C#. It is the relationship between objects.For example, Employee and AddressAn Employee is associated with a single Department, whereas a Department can have more than one employee. Let us see ... Read More
A compound assignment operator has a shorter syntax to assign the result. The operation is performed on the two operands before the result is assigned to the first operand.The following are the compound assignment operators in C#.Sr.NoOperator & Operator Name1+=Addition Assignment2-=Subtraction Assignment3*=Multiplication Assignment4/=Division Assignment5%=Modulo Assignment6&=Bitwise AND Assignment7|=Bitwise OR Assignment8^=Bitwise XOR Assignment9=Right Shift Assignment11=>Lambda OperatorLet us see an example to learn how to work with compound assignment operators in C#.Example Live Demousing System; namespace Program { class MyClass { public static void Main(string[] args) { int val = 7; val ... Read More
To set the color of the bottom border in JavaScript, use the borderBottomColor property. It allows you to set the border color for the bottom of a border.ExampleYou can try to run the following code to learn how to set the color of the bottom border −Live Demo #box { border: 2px dashed blue; width: 120px; height: 120px; } Set border bottom color Demo Text Demo Text function display() { document.getElementById("box").style.borderBottomColor = "yellow"; }
When more than one constructor with the same name is defined in the same class, they are called overloaded, if the parameters are different for each constructor.Let us see an example to learn how to work with Constructor Overloading in C#.In the example, we have two subjects and a string declaration for Student Name.private double SubjectOne; private double SubjectTwo; string StudentName;We are showing result of three students in different subjects. For our example, to show constructor overloading, the name is only displayed for student 3rd.Student s1 = new Student(); Student s2 = new Student(90); Student s3 = new Student("Amit", 88, ... Read More
Compare two enums using the CompareTo() method in C#.The method returns any of the following value −Less than zero: Value of source is less than value of targetZero: Value of source is equal to the value of targetMore than zero: Value of source is more than value of targetExample Live Demousing System; class Program { enum Products { HardDrive = 0, PenDrive = 4, Keyboard = 8 }; static void Main() { Products prod1 = Products.HardDrive; Products prod2 = Products.PenDrive; Products prod3 = Products.Keyboard; Console.WriteLine("Stock for {0} ... Read More
To find the equality between enums, use the Equals() method.Let’s say we have the following Enum.enum Products { HardDrive, PenDrive, Keyboard};Create two Products objects and assign the same values.Products prod1 = Products.HardDrive; Products prod2 = Products.HardDrive;Now check for equality using Equals() method. It would be True since both have the same underlying value.Example Live Demousing System; class Program { enum Products {HardDrive, PenDrive, Keyboard}; enum ProductsNew { Mouse, HeadPhone, Speakers}; static void Main() { Products prod1 = Products.HardDrive; Products prod2 = Products.HardDrive; ProductsNew newProd1 = ProductsNew.HeadPhone; ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP