Ankith Reddy has Published 1070 Articles

How to calculate fractional power using C#?

Ankith Reddy

Ankith Reddy

Updated on 20-Jun-2020 15:24:02

389 Views

To calculate fractional power in C#, use the Math.Pow method.The following sets 5 to the power 3.7 −double res = Math.Pow(5, 3.7);The following is the complete example showing how to calculate fractional power in C# −Example Live Demousing System; class Program {    static void Main() {       double ... Read More

How to pass parameters using param array in a C# method?

Ankith Reddy

Ankith Reddy

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

354 Views

While declaring a method, you are not sure of the number of arguments passed as a parameter. C# param arrays (or parameter arrays) come into help at such times.This is how you can use the param −public int AddElements(params int[] arr) { }The following is the complete example −Exampleusing System; ... Read More

How to demonstrate Prefix Operator using C#?

Ankith Reddy

Ankith Reddy

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

112 Views

The increment operator is ++ operator. If used as prefix on a variable, the value of variable gets incremented by 1. After that the value is returned unlike Postfix operator. It is called Prefix increment operator. In the same way the decrement operator works but it decrements by 1.For example, ++a;The ... Read More

How to use #if..#elif…#else…#endif directives in C#?

Ankith Reddy

Ankith Reddy

Updated on 20-Jun-2020 15:07:13

952 Views

All preprocessor directives begin with #, and only white-space characters may appear before a preprocessor directive on a line. Preprocessor directives are not statements, so they do not end with a semicolon (;).#ifThe #if directive allows testing a symbol or symbols to see if they evaluate to true.#elseIt allows to ... Read More

Stack and Queue in C#

Ankith Reddy

Ankith Reddy

Updated on 20-Jun-2020 15:02:54

4K+ Views

StackStack 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.The following are the methods of Stack class −Sr.No.Method & Description1public virtual void ... Read More

How to assign same value to multiple variables in single statement in C#?

Ankith Reddy

Ankith Reddy

Updated on 20-Jun-2020 14:35:30

2K+ Views

To assign same value to multiple variables in a single line, use the = operator −val1 = val2 = 20;The above statement assigns 20 to the variables val1 and val2 as shown in the following code −Example Live Demousing System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Demo {   ... Read More

What is the Values property of Hashtable class in C#?

Ankith Reddy

Ankith Reddy

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

73 Views

The Values property gets an ICollection containing the values in the Hashtable.Declare Hashtable collection −Hashtable ht = new Hashtable();Now add valuesht.Add("One", "Henry"); ht.Add("Two", "Kevin"); ht.Add("Three", "David");To display values from Hashtable, the following is the code −Example Live Demousing System; using System.Collections; namespace Demo {    class Program {     ... Read More

How does MySQL IF() function work?

Ankith Reddy

Ankith Reddy

Updated on 20-Jun-2020 13:22:56

108 Views

MySQL IF() function is one of the MySQL control flow functions that returns a value based on a condition. It is sometimes referred to as IF ELSE or IF THEN ELSE function. Basically, it takes three expressions and if the first expression is true (not ZERO and not NULL), it ... Read More

What does Array.Length property of array class do in C#?

Ankith Reddy

Ankith Reddy

Updated on 20-Jun-2020 13:21:19

56 Views

The Array.Lenth property in C# is used to find the length of the array.Let’s set the array class first −Array arr = Array.CreateInstance(typeof(String), 3); arr.SetValue("Electronics", 0); arr.SetValue("Clothing", 1); arr.SetValue("Appliances", 2);Now since the array’s length is 3, the Length property will give the result 3 −arr.LengthThe following is the code to ... Read More

What are the difference between Composition and Aggregation in C#?

Ankith Reddy

Ankith Reddy

Updated on 20-Jun-2020 13:19:02

424 Views

Under Composition, if the parent object is deleted, then the child object also loses its status. The composition is a special type of Aggregation and gives a part-of relationship.For example, A Car has an engine. If the car is destroyed, the engine is destroyed as well.public class Engine {    . ... Read More

Advertisements