Chandu yadav has Published 1163 Articles

Style every element that is the child of its parent, counting from the last child with CSS

Chandu yadav

Chandu yadav

Updated on 22-Jun-2020 06:05:54

120 Views

Use the CSS :nth-last-child(n) selector to style every element that is the child of its parent, counting from the last child. You can try to run the following code to implement the :nth-last-child(n) selectorExampleLive Demo                    p:nth-last-child(4) {   ... Read More

How can we assign a bit value as a number to a user variable?

Chandu yadav

Chandu yadav

Updated on 22-Jun-2020 05:35:55

238 Views

As we know that the default type of a bit values assigned to user variables is binary strings but we can also assign a bit value to a number by using the following two methods −By using CAST() functionWith the help of CAST(… AS UNSIGNED) the bit value can be ... Read More

What is the difference between literal and constant in C#?

Chandu yadav

Chandu yadav

Updated on 21-Jun-2020 16:55:46

379 Views

The constants refer to fixed values that the program may not alter during its execution. These fixed values are also called literals. Constants can be of any of the basic data types like an integer constant, a floating constant, a character constant, or a string literal. There are also enumeration ... Read More

What is a non-static class in C#?

Chandu yadav

Chandu yadav

Updated on 21-Jun-2020 16:51:45

956 Views

Non-static classes can be instantiated, whereas static classes cannot be instantiated i.e. you cannot use the new keyword to create a variable of the class type.Non-static classes can have instance method and static methods.Access the members of a static class by using the class name itself, whereas Static class is sealed.Example of ... Read More

String format for Double in C#

Chandu yadav

Chandu yadav

Updated on 21-Jun-2020 16:35:00

1K+ Views

Use the static method String.Format for form double string format in C#.For three decimal places −String.Format("{0:0.000}", 987.383); String.Format("{0:0.000}", 987.38); String.Format("{0:0.000}", 987.7899);For thousands separator −String.Format("{0:0, 0.0}", 54567.46); String.Format("{0:0, 0}", 54567.46);To format string −Exampleusing System; class Demo {    public static void Main(String[] args) {       Console.WriteLine("Three decimal ... Read More

Private Methods in C#

Chandu yadav

Chandu yadav

Updated on 21-Jun-2020 16:26:34

6K+ Views

Private Methods can only be used inside the class. To set private methods, use the private access specifier.Private access specifier allows a class to hide its member variables and member functions from other functions and objects. Only functions of the same class can access its private members. Even an instance ... Read More

Optional property in a C# class

Chandu yadav

Chandu yadav

Updated on 21-Jun-2020 16:11:09

4K+ Views

A property is optional if it is possible and valid for it to have null. A property whose CLR type cannot have null cannot be configured optional.An example optional attribute usage −Example[AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = false)] internal sealed class OptionalAttribute : Attribute { } public class Employee ... Read More

Print with your own font using C#

Chandu yadav

Chandu yadav

Updated on 21-Jun-2020 16:03:42

317 Views

To print your own font in C#, firstly construct −FontFamily objectFont ObjectThe FontFamily object sets the typeface like Arial, TimesNewRoman, etc, whereas the Font object sets the size and style of font.Let us create an Arial font style.FontFamily myFontFamily = new FontFamily("Arial"); Font myFont = new Font( myFontFamily, 20, FontStyle.Bold, ... Read More

Reverse a string in C#

Chandu yadav

Chandu yadav

Updated on 21-Jun-2020 15:54:35

436 Views

To reverse a string, use the Array. Reverse() method.We have set a method and passed the string value as “Henry” −public static string ReverseFunc(string str) {    char[] ch = str.ToCharArray();    Array.Reverse(ch);    return new string(ch); }In the above method, we have converted the string into character array −char[] ... Read More

Reverse words in a given String in C#

Chandu yadav

Chandu yadav

Updated on 21-Jun-2020 15:53:26

510 Views

Let’s say the following is the string −WelcomeAfter reversing the string, the words should be visible like −emocleWUse the reverse() method and try the following code to reverse words in a string −Exampleusing System; using System.Linq; class Demo {    static void Main() {       string ... Read More

Advertisements