Karthikeya Boyini has Published 1385 Articles

How to use NameValueCollection class in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 20-Jun-2020 17:10:28

734 Views

The NameValueCollection sets more than one value for a single key. Now let us see how to use them in our C# program.Set the collection −static NameValueCollection GetCollection() {    NameValueCollection myCollection = new NameValueCollection();    myCollection.Add("Tim", "One");    myCollection.Add("John", "Two");    myCollection.Add("Jamie", "Three");    return myCollection; }Now with the ... Read More

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

133 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

4K+ 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

1K+ 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

1K+ 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

Push vs pop in stack class in C#

karthikeya Boyini

karthikeya Boyini

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

712 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 use #undef directive in C#?

karthikeya Boyini

karthikeya Boyini

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

320 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

Major features of C# programming

karthikeya Boyini

karthikeya Boyini

Updated on 20-Jun-2020 14:49:42

2K+ Views

C# is a modern, general-purpose, object-oriented programming language developed by Microsoft. C# is designed for Common Language Infrastructure (CLI), which consists of the executable code and runtime environment that allows the use of various high-level languages on different computer platforms and architectures.The following are the major features of C# −Following ... Read More

Ternary Operator in C#

karthikeya Boyini

karthikeya Boyini

Updated on 20-Jun-2020 14:43:03

3K+ Views

Ternary operator is a Conditional operator in C#. It takes three arguments and evaluates a Boolean expression.For example −b = (a == 1) ? 20 : 30;Above, if the first operand evaluates to true (1), the second operand is evaluated. If the first operand evaluates to false (0), the third ... Read More

Advertisements