Samual Sam has Published 2492 Articles

How to declare and use Interfaces in C#?

Samual Sam

Samual Sam

Updated on 20-Jun-2020 10:24:46

126 Views

Interfaces define properties, methods, and events, which are the members of the interface. Interfaces contain only the declaration of the members. It is the responsibility of the deriving class to define the members.Let us declare interfaces −public interface ITransactions {    // interface members    void showTransaction();    double getAmount(); ... Read More

What are delegates in C#?

Samual Sam

Samual Sam

Updated on 20-Jun-2020 10:21:40

202 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

What are different methods of passing parameters in C#?

Samual Sam

Samual Sam

Updated on 20-Jun-2020 10:16:10

327 Views

When a method with parameters is called, you need to pass the parameters to the method using any of the following three methods -Reference ParametersThis method copies the reference to the memory location of an argument into the formal parameter. This means that changes made to the parameter affect the ... Read More

How to declare an empty string array in C#?

Samual Sam

Samual Sam

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

2K+ Views

In C#, you can use strings as an array of characters, However, more common practice is to use the string keyword to declare a string variable. The string keyword is an alias for the System.String class.To declare an empty string.string[] arr = new string[] {}; // empty stringNow let us ... Read More

Write a C# program to check if a number is prime or not

Samual Sam

Samual Sam

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

3K+ Views

To calculate whether a number is prime or not, we have used a loop and within that on every iteration, we have an if statement to find that the remainder is equal to 0, between the number itself.for (int i = 1; i

How to use RightShift Operators in C#?

Samual Sam

Samual Sam

Updated on 20-Jun-2020 10:07:26

100 Views

The left operands value is moved right by the number of bits specified by the right operand in Right Shift Operator.Let us see an example of Right Shift operator in C# −using System; namespace OperatorsAppl {    class Program {       static void Main(string[] args) ... Read More

How to concatenate Two Arrays in C#?

Samual Sam

Samual Sam

Updated on 20-Jun-2020 10:02:38

342 Views

To concatenate two arrays in C#, let us first declare and initialize the array. Here, we have considered a string array −string[] str = new string[] { "Hello", "World" };Now let us use the join() method to concatenate −.string.Join(" ", str);Now let us see the complete code to concatenate two ... Read More

What are control statements in C#?

Samual Sam

Samual Sam

Updated on 20-Jun-2020 09:59:29

6K+ Views

The flow of program control is specified by control statements in C#. It includes the following −if statementAn if statement consists of a boolean expression followed by one or more statements.The following is the syntax −if(boolean_expression) {    /* statement(s) will execute if the boolean expression is true */ }if-else ... Read More

How to use ‘as’ operator in C#?

Samual Sam

Samual Sam

Updated on 20-Jun-2020 09:57:12

241 Views

The "as" operator perform conversions between compatible types. It is like a cast operation and it performs only reference conversions, nullable conversions, and boxing conversions. The as operator can't perform other conversions, such as user-defined conversions, which should instead be performed by using cast expressions.The following is an example showing ... Read More

Write a C# program to check if a number is divisible by 2

Samual Sam

Samual Sam

Updated on 20-Jun-2020 09:54:42

2K+ Views

To check if a number is divisible by2 or not, you need to first find the remainder.If the remainder of the number when it is divided by 2 is 0, then it would be divisible by 2.Let’s say our number is 10, we will check it using the following if-else ... Read More

Advertisements