The window object includes the location object in JavaScript. It includes the following properties −window.location.hrefIt returns the URL of the current page.Example Click below to get the complete URL of the page. URL function display() { var res = location.href; document.write(res); } window.location.replaceIt is used to replace the current document.Example Replace current document function display() { location.replace("https://www.qries.com") } window.location.assignIf you want to load a new document, use JavaScript assign.Example Open new document function display() { location.assign("https://www.qries.com") }
Firstly, declare and initialize two numbers.int num1 = 50; int num2 = 90;With that, use if-else to find the maximum number.if (num1 > num2) { maxNum = num1; } else { maxNum = num2; }Above, we have set the maximum value to the variable maxNum and printed it later on.The following is the complete example to find maximum between 2 numbers in C#.Example Live Demousing System; namespace Demo { class Program { static void Main(string[] args) { int num1 = 50; int num2 = 90; ... Read More
Threads are lightweight processes. A thread is defined as the execution path of a program. Threads are created by extending the Thread class. The extended Thread class then calls the Start() method to begin the child thread execution.Example of Thread: One common example of use of thread is implementation of concurrent programming by modern operating systems. Use of threads saves wastage of CPU cycle and increase efficiency of an application.The following is an example showing how to create a thread.Example Live Demousing System; using System.Threading; namespace Demo { class Program { public static void ThreadFunc() { ... Read More
Firstly, set two items in the tuple.Tuple tuple = new Tuple(20, "Tom");Now check for first item in the tuple, which is an integer.if (tuple.Item1 == 20) { Console.WriteLine(tuple.Item1); }Now check for second item in the tuple, which is a string −if (tuple.Item2 == "Tom") { Console.WriteLine(tuple.Item2); }The following is an example to create a tuple with string and int items.Example Live Demousing System; using System.Threading; namespace Demo { class Program { static void Main(string[] args) { Tuple tuple = new Tuple(20, "Tom"); if (tuple.Item1 == 20) { ... Read More
An infinite loop is a loop that never terminates and repeats indefinitely.Let us see an example to create an infinite loop in C#.Exampleusing System; namespace Demo { class Program { static void Main(string[] args) { for (int a = 0; a < 50; a--) { Console.WriteLine("value : {0}", a); } Console.ReadLine(); } } }Above, the loop executes until a < 50. The value of is set to 0 initially.int a = 0;The value of a decrements after each iteration since it is set to.a--;Therefore the value of a will never be above 50 and the condition a
Dynamic arrays are growable arrays and have an advantage over static arrays. This is because the size of an array is fixed.To create arrays dynamically in C#, use the ArrayList collection. It represents ordered collection of an object that can be indexed individually. It also allows dynamic memory allocation, adding, searching and sorting items in the list.The following is an example showing how to create arrays in dynamically in C#.Example Live Demousing System; using System.Collections; namespace CollectionApplication { class Program { static void Main(string[] args) { ArrayList al = new ArrayList(); ... Read More
The columnRule property is used in JavaScript to set the column rule. It allows you to set the style, color, and width between column rule.ExampleYou can try to run the following code to set the column rule properties with JavaScript −Live Demo Click below to create 4 columns Columns This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is ... Read More
To set all the font properties, use the JavaScript font property. You can try to run the following code to set all font properties in a single declaration with JavaScript −ExampleLive Demo Heading 1 This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text. Set Font function display() { document.getElementById("myID").style.font = "italic 15px verdana,sans-serif"; }
Custom attributes that can be used to store declarative information and can be retrieved at run-time.Let us see how to declare custom attribute.[AttributeUsage ( AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Field | AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = true)] public class DeBugInfo : System.AttributeFor our example, let us construct a custom attribute named DeBugInfo, which stores the information obtained by debugging any program.The DeBugInfo class has three private properties for storing the first three information and a public property for storing the message. Hence the bug number, developer's name, and date of review are the positional parameters of the DeBugInfo class and the ... Read More
Yes, use new RegExp(pattern, flags) to achieve this in JavaScript.You can try to run the following code to implement JavaScript regex using string variables − var str = 'HelloWorld'.replace( new RegExp('hello', 'i'), '' ); document.write(str);
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP