Karthikeya Boyini has Published 2383 Articles

C# Nullable Datetime

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 09:50:16

12K+ Views

Using the DateTime nullable type, you can assign the null literal to the DateTime type.A nullable DateTime is specified using the following question mark syntax.DateTime?The following is the code to implement Nullable Datetime.Example Live Demousing System; class Program {    static void Main() {       DateTime? dt = null; ... Read More

Date Class in C#

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 09:49:22

13K+ Views

To set dates in C#, use DateTime class. The DateTime value is between 12:00:00 midnight, January 1, 0001 to 11:59:59 P.M., December 31, 9999 A.D.Let’s create a DateTime object.Example Live Demousing System; class Test {    static void Main() {       DateTime dt = new DateTime(2018, 7, 24);   ... Read More

C# program to Count words in a given string

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 09:42:41

530 Views

Let’s say we want to count the number of words in the following string −str1 = "Hello World!";Now you need to loop though till string length and increment the variable count on finding “ “, , \t as shown below −if(str1[a]==' ' || str1[a]=='' || str1[a]=='\t') {    count++; }You ... Read More

Difference between IEnumerator and IEnumerable Interface in C#

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 09:39:54

5K+ Views

IEnumerable and IEnumerator both are interfaces in C#.IEnumerable is an interface defining a single method GetEnumerator() that returns an IEnumerator interface.This works for readonly access to a collection that implements that IEnumerable can be used with a foreach statement.IEnumerator has two methods MoveNext and Reset. It also has a property ... Read More

Difference between IComparable and IComparer Interface in C#

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 09:33:14

2K+ Views

IComparable Interface in C#Use the IComparable Interface in C# to sort elements. It is also used to compare the current instance with another object of same type.It provides you with a method of comparing two objects of a particular type. Remember, while implementing the IComparable interface, CompareTo() method should also ... Read More

Constructors in C#

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 09:27:50

369 Views

A Constructor in C# gets invoked automatically when a object gets created. The constructor has the same name as that of the class, for example −public class Department {    public Department () {       Console.WriteLine("Default Constructor! ");    } }The following is the code that shows the ... Read More

Difference between == and .Equals method in c#

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 09:23:20

6K+ Views

The Equality Operator ( ==) is the comparison operator and the Equals() method in C# is used to compare the content of a string.The Equals() method compares only content.Example Live Demousing System; namespace ComparisionExample {    class Program {       static void Main(string[] args) {         ... Read More

What will happen when 0 is converted to Number in JavaScript?

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 09:22:27

65 Views

Use the Number() method in JavaScript to convert to Number. You can try to run the following code to learn how to convert 0 to Number in JavaScript −ExampleLive Demo           Convert 0 to Number                var myVal = 0;          document.write("Number: " + Number(myVal));          

C# Enum GetName Method

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 09:19:43

1K+ Views

The GetName() method returns the names of the constants in the Enumeration.Here is the enum.enum Stock { Appliance, Clothing, Footwear };Now, get the names using the Enum.GetName() method. Just set the constant and retrieve the individual name.Enum.GetName(typeof(Stock), 1Let us see the example now.Example Live Demousing System; class Demo {    enum ... Read More

Complex Numbers in C#

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 09:17:01

2K+ Views

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 ... Read More

Advertisements