Articles on Trending Technologies

Technical articles with clear explanations and examples

What does the interface IStructuralEquatable do in C#?

Samual Sam
Samual Sam
Updated on 20-Jun-2020 475 Views

The IStructuralEquatable interface defines methods to support the comparison of objects for structural equality, which means that two objects are equal because they have equal values.It includes the following two methods −Sr.NoMethod & Description1Equals(Object,  IEqualityComparer)The method determined whether an object is structurally equal to the current instance.2GetHashCode(IEqualityComparer)The methods a hash code for the current instance.Let us see an example in which I have created Tuple objects and worked with IstructuralEquatable interface:Create Tuples −var tupleOne = Tuple.Create(26.3, Double.NaN, 35.6); var tupleOne = Tuple.Create(26.3, Double.NaN, 35.6);Now check the equality by calling IStructuralEquatable.Equals using default comparer.IStructuralEquatable chk = tupleOne; Console.WriteLine(chk.Equals(tupleTwo, EqualityComparer.Default));

Read More

Time Functions in C#

Chandu yadav
Chandu yadav
Updated on 20-Jun-2020 1K+ Views

The DateTime has methods and properties for Date and Time as well like how to get the number of hours or minutes of a day, etc.Let us only focus on the time functions −Refer MSDN (Microsoft Developer Network) for all the functions −Sr.No.Method & Properties1AddDays(Double)Returns a new DateTime that adds the specified number of days to the value of this instance.2AddHours(Double)Returns a new DateTime that adds the specified number of hours to the value of this instance.3AddMilliseconds(Double)Returns a new DateTime that adds the specified number of milliseconds to the value of this instance.4AddMinutes(Double)Returns a new DateTime that adds the specified ...

Read More

How to display Absolute value of a number in C#?

Arjun Thakur
Arjun Thakur
Updated on 20-Jun-2020 3K+ Views

To find the absolute value of a number in C#, use the Math.Abs method.Set numbers first −int val1 = 77; int val2 = -88;Now take two new variables and get the Absolute value of the above two numbers −int abs1 = Math.Abs(val1); int abs2 = Math.Abs(val2);Let us see the complete code to display Absolute value of a number −Example Live Demousing System; class Program {    static void Main() {       int val1 = 77;       int val2 = -88;       Console.WriteLine("Before...");       Console.WriteLine(val1);       Console.WriteLine(val2);       ...

Read More

How to check whether a string contains a substring in jQuery?

Kristi Castro
Kristi Castro
Updated on 20-Jun-2020 3K+ Views

The jQuery :contains() Selector is used to check whether a string contains a substring in jQuery.Set the substring you are searching for in the contains() method as shown below:$(document).ready(function(){    $("p:contains(Video)").css("background-color", "blue"); });Now, let us see the complete code to check whether a string contains a substring or not:Example Live Demo               $(document).ready(function(){          $("p:contains(Video)").css("background-color", "blue");       });     Tutorialspoint This is demo text. Free Tutorials Free Video Tutorials

Read More

What is compile time polymorphism in C#?

Samual Sam
Samual Sam
Updated on 20-Jun-2020 2K+ Views

Polymorphism can be static or dynamic. In static polymorphism, the response to a function is determined at the compile time. In dynamic polymorphism, it is decided at run-time.The linking of a function with an object during compile time is called early binding. It is also called static binding. C# provides two techniques to implement static polymorphism. They are Function overloading and Operator overloading.In function overloading you can have multiple definitions for the same function name in the same scope. The definition of the function must differ from each other by the types and/or the number of arguments in the argument ...

Read More

What is composition in C#?

Arjun Thakur
Arjun Thakur
Updated on 20-Jun-2020 614 Views

If the parent object is deleted under Composition, then the child object also loses its status. The 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();       ....... }

Read More

What is a parameterized constructor in C# programs?

Chandu yadav
Chandu yadav
Updated on 20-Jun-2020 3K+ Views

In a constructor you can also add parameters. Such constructors are called parameterized constructors. This technique helps you to assign initial value to an object at the time of its creation.The following is an example −// class class DemoParameterized constructor with a prarameter rank −public Demo(int rank) { Console.WriteLine("RANK = {0}", rank); }Here is the complete example displaying how to work with parameterized constructor in C# −Example Live Demousing System; namespace Demo {    class Line {       private double length; // Length of a line             public Line(double len) { //Parameterized constructor ...

Read More

What is late binding in C#?

Samual Sam
Samual Sam
Updated on 20-Jun-2020 1K+ Views

In static polymorphism, the response to a function is determined at the compile time. In dynamic polymorphism, it is decided at run-time. Dynamic polymorphism is what we call late binding.Dynamic polymorphism is implemented by abstract classes and virtual functions. The following is an example showing an example of dynamic polymorphism −Example Live Demousing System; namespace PolymorphismApplication {    class Shape {       protected int width, height;       public Shape( int a = 0, int b = 0) {          width = a;          height = b;       ...

Read More

How to make a textarea and input type read only using jQuery?

Kristi Castro
Kristi Castro
Updated on 20-Jun-2020 3K+ Views

To make a textarea and input type read only, use the attr() method .For readonly, set the input type text and textarea as read only as shown below:$('input[type="text"], textarea').each(function(){    $(this).attr('readonly','readonly'); });The following is the code to set readonly to textarea and input type:Example Live Demo jQuery Example               $(document).ready(function() {          $('input[type="text"], textarea').each(function(){             $(this).attr('readonly','readonly');          });       });     readonly textarea

Read More

How to disable/ enable checkbox with jQuery?

Kristi Castro
Kristi Castro
Updated on 20-Jun-2020 6K+ Views

fTo disable and enable checkbox, use the attr() method.Initially set the input type checkbox and disable it −MaleNow on the click of a button, toggle between disabled and enabled checkbox −$("#button1").click(function() {    $("#sName").attr('disabled', !$("#sName").attr('disabled')); });Example Live Demo jQuery Example               $(document).ready(function() {          $("#button1").click(function() {             $("#sName").attr('disabled', !$("#sName").attr('disabled'));          });       });     Male

Read More
Showing 44761–44770 of 61,248 articles
Advertisements