Karthikeya Boyini has Published 2193 Articles

How to declare a delegate in C#?

karthikeya Boyini

karthikeya Boyini

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

293 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

280 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

What are pointer data types in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 20-Jun-2020 14:45:09

2K+ Views

A pointer is a variable whose value is the address of another variable i.e., the direct address of the memory location. Similar to any variable or constant, you must declare a pointer before you can use it to store any variable address.The syntax of a pointer is −type *var-name;The 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

How to get int value from enum in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 20-Jun-2020 14:41:32

239 Views

Firstly, set the enum −public enum Vehicle { Car, Bus, Truck }Now use typecasting to cast an enum to int −int a = (int)Vehicle.Car;The following is the complete code to cast an enum to int −Example Live Demousing System; public class Demo {    public enum Vehicle { Car, Bus, ... Read More

C# program to print all the common elements of two lists

karthikeya Boyini

karthikeya Boyini

Updated on 20-Jun-2020 14:37:48

2K+ Views

Firstly create the two lists −List list1 = new List() {40, 20, 60, 3, 55}; List list2 = new List() {20, 70, 55, 80};To find the common elements, use the Intersect −list1.Intersect(list2)The following is the complete code to find the common elements between the two lists −Example Live Demousing System; using ... Read More

C# program to print all sublists of a list

karthikeya Boyini

karthikeya Boyini

Updated on 20-Jun-2020 14:34:45

668 Views

Firstly, create a list −List list = new List();The string here is “xyz” for which we will find the sublists. While looping we will declare another list, that would generate sublists on every true iteration −for (int i = 1; i < str.Length; i++) {    list.Add(str[i - 1].ToString());   ... Read More

What is the use of sizeof Operator in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 20-Jun-2020 14:20:00

433 Views

The sizeof() datatype returns the size of a data type. Let’s say you need to find the size of int datatype −sizeof(int);For double datatype −sizeof(double);Let us see the complete example to find the size of various datatypes −Example Live Demousing System; namespace Demo {    class Program { ... Read More

What is the use of ‘new’ keyword in C#?

karthikeya Boyini

karthikeya Boyini

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

862 Views

Use the new keyword to create an instance of the array −int [] a = new int[5];The new operator is used to create an object or instantiate an object. Here in the example, an object is created for the class using the new −Example Live Demousing System; namespace CalculatorApplication { ... Read More

Advertisements