Hidden Features of Chash

Chandu yadav
Updated on 21-Jun-2020 12:06:09

422 Views

The following are the hidden or lesser known useful features of C# −Lambda ExpressionsA lambda expression in C# describes a pattern. It has the token => in an expression context. This is called goes to operator and used when a lambda expression is declared.NullablesC# provides a special data types, the nullable types, to which you can assign normal range of values as well as null values. The following is the syntax − ? = null;Null Coalescing OperatorThe null coalescing operator is used with the nullable value types and reference types. It is used for converting an operand to the ... Read More

Interfaces Implemented by Array Class in Chash

Samual Sam
Updated on 21-Jun-2020 12:05:51

1K+ Views

System.Array implements interfaces, like ICloneable, IList, ICollection, and IEnumerable, etc. The ICloneable interface creates a copy of the existing object i.e a clone.Let us see learn about the ICloneable interface. It only has a Clone() methods because it creates a new object that is a copy of the current instance.The following is an example showing how to perform cloning using ICloneable interface −Exampleusing System; class Car : ICloneable {    int width;    public Car(int width) {       this.width = width;    }    public object Clone() {       return new Car(this.width);   ... Read More

Extender Provider Components in C#

George John
Updated on 21-Jun-2020 11:58:57

225 Views

To provide properties to other components, the extender provider is used. Let’s consider an example of a TooTtip component.You add the component to a form. This sets a ToolTip property to every control. The same property is not under the attacked PropertyGrid control.myTooltip1.SetToolTip(btn1, "This is ToolTip!");Let us see how to implement extender provider component −Firstly, define a component −public class MyExtender : IExtenderProvider {...}IExtenderProvider definition −public interface IExtenderProvider {    bool newExtend(object extendeNew); }Now you need to implement the newExtend method. This is done to return true for every related component or control.

What are Punctuators in C#

karthikeya Boyini
Updated on 21-Jun-2020 11:58:22

653 Views

Punctuators are used in C# as special symbols to a group or divide the code. It includes −] () {}, ; * = #For example, = gets included in a class or even while declaring a variable. Statement ends with a semi-colon −int a = 10;In a class, the braces are used −class Demo { }While declaring a dictionary −var d = new Dictionary(5);It is also used while declaring and initializing a list −List myList = new List() {    "mammals",    "reptiles",    "amphibians" };

What are Sealed Modifiers in C#

Ankith Reddy
Updated on 21-Jun-2020 11:57:56

511 Views

When you use sealed modifiers in C# on a method, then the method loses its capabilities of overriding. The sealed method should be part of a derived class and the method must be an overridden method.Let us see an example −The following example won’t allow you to override the method display() because it has a sealed modifier for the ClassTwo derived class −ClassOne is our base class, whereas ClassTwo and ClassThree are derived classes −Exampleclass ClassOne {    public virtual void display() {       Console.WriteLine("baseclass");    } } class ClassTwo : ClassOne {    public sealed override ... Read More

What are Static or Fixed-Length Arrays in C#

Samual Sam
Updated on 21-Jun-2020 11:56:11

2K+ Views

A static array is a data structure with a fixed size. Let us see an example of a static array in C#.Here is a static string array. The data remains the same here i.e. fixed −static string[] _fruits = new string[] {    "apple",    "mango" };Now let us see the complete example to create and access static arrays in C# −Exampleusing System; class Demo {    static void Main() {       foreach (string fruits in Program.Fruits) {          Console.WriteLine(fruits);       }    } } public static class Program {    static string[] _fruits = new string[] {       "apple",       "mango"    };    public static string[] Fruits {       get {          return _fruits;       }    } }

Set the Color of the Four Borders Using CSS

Chandu yadav
Updated on 21-Jun-2020 10:23:16

82 Views

To set the color of the four borders, use the border-color property. You can try to run the following code to set border color for all the bordersExampleLive Demo                    p {             border-style: dashed;             border-color: #808000 #800000 #FF0000 #FFFF00;          }                     This is demo text with four colored border.     Output

Set the Width of the Left Border Using CSS

seetha
Updated on 21-Jun-2020 10:20:40

71 Views

To set the width of the left border, use the border-left-width property in CSS. You can try to run the following code to implement the border-left-width property −ExampleLive Demo                    p {             border-style: dashed;             border-left-width: 10px;          }                     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

Set the Style of the Bottom Border Using CSS

George John
Updated on 21-Jun-2020 10:18:13

226 Views

To set the style of the bottom border, use the border-bottom-style property. The values for the border you can set is, dotted, double, dashed, solid, etc.ExampleYou can try to run the following code to style bottom borderLive Demo                    p.dotted {border-bottom-style: dotted;}          p.double {border-bottom-style: double;}          p.dashed {border-bottom-style: dashed;}          p.solid {border-bottom-style: solid;}          p.inset {border-bottom-style: inset;}          p.outset {border-bottom-style: outset;}                     Dotted bottom border.       Double bottom border.       Dashed bottom border.       Solid bottom border.       Inset bottom border.       Outset bottom border.     Output

Role of CSS nth-last-of-type(n) Selector

mkotla
Updated on 21-Jun-2020 08:48:30

175 Views

Use the CSS :nth-last-of-type(n) selector to select every element that is the second element of its parent, counting from the last child.ExampleYou can try to run the following code to implement the :nth-last-of-type(n) selector:Live Demo                    p:nth-last-of-type(2) {             background: blue;             color: white;          }                     This is demo text 1.       This is demo text 2.       This is demo text 3.       This is demo text 4.       This is demo text 5.    

Advertisements