- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 2628 Articles for Csharp
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 { static void Main(string[] args) { Hashtable ht = new Hashtable(); ht.Add("One", "Henry"); ht.Add("Two", "Kevin"); ht.Add("Three", "David"); // Displaying values foreach (string value in ht.Values) { Console.WriteLine(value); } Console.ReadKey(); } } }OutputDavid Henry Kevin
700 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 { class NumberManipulator { public void swap(int x, int y) { int temp; temp = x; /* save the value of x */ x = y; /* put y into x */ ... Read More
1K+ Views
To calculate the power exponent value, use the Math.pow() method.Here, n is the number and p is the power −double res = Math.Pow(n, p);The following is the complete code −Example Live Demousing System; class Program { static void Main() { double n, p; n = 7; p = 3; Console.WriteLine("Exponent Power= "+n); double res = Math.Pow(n, p); Console.WriteLine("Result= {0}", res); Console.ReadLine(); } }OutputExponent Power= 7 Result= 343
347 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 { static void Main(string[] args) { Console.WriteLine("The size of long is {0}", sizeof(long)); Console.WriteLine("The size of double is {0}", sizeof(double)); Console.ReadLine(); } } }OutputThe size of long is 8 The size of double is 8
96 Views
A loop statement allows us to execute a statement or a group of statements multiple times. The following are the loops supported in C# −Sr.NoLoop Type & Description1while loopIt repeats a statement or a group of statements while a given condition is true. It tests the condition before executing the loop body.2for loopIt executes a sequence of statements multiple times and abbreviates the code that manages the loop variable.3do...while loopIt is similar to a while statement, except that it tests the condition at the end of the loop bodyWith C#, you can also use foreach loop as shown below −Example Live ... Read More
124 Views
The Array.LongLength property gets a 64-bit integer that represents the total number of elements in all the dimensions of the Array.Let’s say your array of long data type is −long[,] arr1= new long[15, 35];Use the LongLength property to get an integer representing the total number of elements in all dimensions of the Array −arr1.LongLengthLet us see an example to implement the Array.LongLength property of array class −Example Live Demousing System; class Program { static void Main() { long[,] arr1= new long[15, 35]; long len1 = arr1.GetLongLength(0); Console.WriteLine(len1); Console.WriteLine(arr1.LongLength); } }Output15 525
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 implement Array.Length property of array class −Example Live Demousing System; using System.Collections.Generic; using System.Linq; using System.Text; namespace lower { class Program { static void Main(string[] args) { Array arr = Array.CreateInstance(typeof(String), 3); arr.SetValue("Electronics", 0); ... Read More
2K+ Views
C# provides two techniques to implement static polymorphism −Function overloadingOperator overloadingFunction OverloadingTwo or more than two methods having the same name but different parameters is what we call function overloading in C#.Function 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, then our overloaded methods will have the same name but different number of arguments −public static int mulDisplay(int one, int two) { } public static int mulDisplay(int one, int two, int three) { } public static int mulDisplay(int one, ... Read More
80 Views
The Array.IsReadOnly property gets a value indicating whether the Array is read-only.Firstly, set the array values −Array arr = Array.CreateInstance(typeof(String), 3); arr.SetValue("Electronics", 0); arr.SetValue("Clothing", 1);Now let’s use the IsReadOnly property to find whether the Array is read-only. If the array is read-only, then it cannot be updated −arr.IsReadOnlyThe following is the complete example stating the usage of Array.IsReadOnly property −Example Live Demousing System; using System.Collections.Generic; using System.Linq; using System.Text; namespace lower { class Program { static void Main(string[] args) { Array arr = Array.CreateInstance(typeof(String), 3); arr.SetValue("Electronics", 0); ... Read More