Karthikeya Boyini has Published 2383 Articles

What is method overloading in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 20-Jun-2020 15:38:14

2K+ Views

Two or more than two methods having the same name but different parameters is what we call method overloading in C#.Method overloading in C# can be performed by changing the number of arguments and the data type of the arguments.Let’s say you have a function that prints multiplication of numbers, ... Read More

What is the Item property of BitArray class in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 20-Jun-2020 15:30:41

67 Views

The Item property of the BitArray class gets or sets the value of the bit at a specific position in the BitArray.Use the keyword to define the indexers instead of implementing the Item property. To access an element, use the mycollection[index].The following is the implementation of BitArray class Item property ... Read More

How to calculate the Size of Folder using C#?

karthikeya Boyini

karthikeya Boyini

Updated on 20-Jun-2020 15:26:47

3K+ Views

To calculate the size of a folder in C#, use the Directory.EnumerateFiles Method and get the files.To get the sub- directories, use the EnumerateDirectories method. Our folder is set using DirectoryInfo class −DirectoryInfo info = new DirectoryInfo(@"D:/new");Now find the size −long totalSize = info.EnumerateFiles().Sum(file => file.Length); For the directories, use ... Read More

What are postfix operators in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 20-Jun-2020 15:23:14

599 Views

The increment operator is ++ operator. If used as postfix on a variable, the value of the variable is first returned and then gets incremented by 1. It is called Postfix increment operator. In the same way, the decrement operator works but it decrements by 1.For example, a++;The following is ... Read More

What does the interface IList do in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 20-Jun-2020 15:21:31

791 Views

The IList interface has a non-generic collection of objects that can be individually accessed by index.The following are the properties of interface IList in C# −Sr.NoProperty Name & Description1CountGets the number of elements contained in the ICollection.2isFixedSizeGets a value indicating whether the IList has a fixed size.3isReadOnlyGets a value indicating ... Read More

What are the different data types of arrays in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 20-Jun-2020 15:19:31

550 Views

With C#, you can create an array of integers, chars, etc. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type stored at contiguous memory locations. This type can be ... Read More

How to display the IP Address of the Machine using C#?

karthikeya Boyini

karthikeya Boyini

Updated on 20-Jun-2020 15:10:52

557 Views

Use the IPHostEntry.AddressList Property to get IP Address −IPHostEntry myIP = Dns.GetHostEntry(hostName); IPAddress[] address = myIP.AddressList;Try the following code to display IP address −Exampleusing System; using System.Net; class Program {    static void Main() {       String hostName = string.Empty;       hostName = Dns.GetHostName();   ... Read More

Push vs pop in stack class in C#

karthikeya Boyini

karthikeya Boyini

Updated on 20-Jun-2020 15:04:44

385 Views

Stack class represents a last-in, first out collection of object. It is used when you need a last-in, first-out access of items.The following is the property of Stack class −Count − Gets the number of elements in the stack.Push OperationAdd elements in the stack using the Push operation −Stack st ... Read More

How to declare a delegate in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 20-Jun-2020 15:00:01

199 Views

A delegate in C# is a reference to the method. A delegate is a reference type variable that holds the reference to a method. The reference can be changed at runtime.Delegates are especially used for implementing events and the call-back methods. All delegates are implicitly derived from the System.Delegate class.Let ... Read More

How to use #undef directive in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 20-Jun-2020 14:55:18

205 Views

The #undef directive allows you to undefine a symbol. The following is the syntax −#undef SYMBOLFor example, #undef OneIt evaluates to false when used along with #if directive. Let us see an example −Example Live Demo#define One #undef Two using System; namespace Demo {    class Program {   ... Read More

Advertisements