
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 2587 Articles for Csharp

630 Views
To get all elements of a List that match the conditions specified by the predicate, the code is as follows −Exampleusing System; using System.Collections.Generic; public class Demo { private static bool demo(int i) { return ((i % 3) == 0); } public static void Main(String[] args) { List list = new List(); list.Add(9); list.Add(15); list.Add(20); list.Add(40); list.Add(50); list.Add(60); Console.WriteLine("List elements..."); foreach (int i in list) { ... Read More

262 Views
To get hash code for the specified key of a Hashtable, the code is as follows −Example Live Demousing System; using System.Collections; public class HashCode : Hashtable { public static void Main(string[] args) { HashCode hash = new HashCode(); hash.Add("A", "Jacob"); hash.Add("B", "Mark"); hash.Add("C", "Tom"); hash.Add("D", "Nathan"); hash.Add("E", "Tim"); hash.Add("F", "John"); hash.Add("G", "Gary"); Console.WriteLine("Key and Value pairs..."); foreach(DictionaryEntry entry in hash) { Console.WriteLine("{0} and {1} ", ... Read More

166 Views
To get synchronize access to the ListDictionary, the code is as follows −Example Live Demousing System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main() { ListDictionary dict = new ListDictionary(); dict.Add("1", "SUV"); dict.Add("2", "Sedan"); dict.Add("3", "Utility Vehicle"); dict.Add("4", "Compact Car"); dict.Add("5", "SUV"); dict.Add("6", "Sedan"); dict.Add("7", "Utility Vehicle"); dict.Add("8", "Compact Car"); dict.Add("9", "Crossover"); dict.Add("10", "Electric Car"); Console.WriteLine("ListDictionary elements..."); ... Read More

210 Views
Let us first create a table −mysql> create table DemoTable -> ( -> Value int -> ); Query OK, 0 rows affected (0.63 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(78); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(89); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(98); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(58); Query OK, 1 row affected (0.25 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output ... Read More

268 Views
Let us first create a table −mysql> create table DemoTable -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentMarks int -> ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command. We have also inserted duplicate records −mysql> insert into DemoTable(StudentMarks) values(98); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable(StudentMarks) values(98); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable(StudentMarks) values(78); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable(StudentMarks) values(78); Query OK, 1 row affected (0.29 sec) mysql> insert ... Read More

987 Views
To insert data from one table to another, use the INSERT INTO SELECT statement. Let us first create a table −mysql> create table DemoTable1 -> ( -> Id int, -> FirstName varchar(20) -> ); Query OK, 0 rows affected (0.49 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1 values(101, 'Adam'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1 values(102, 'John'); Query OK, 1 row affected (0.11 sec)Display all records from the table using select statement −mysql> select *from DemoTable1;This will produce the following output −+------+-----------+ | Id ... Read More

125 Views
To get the HashCode for the current UInt32 instance, the code is as follows −Example Live Demousing System; public class Demo { public static void Main() { uint val1 = 100; uint val2 = UInt16.MinValue; Console.WriteLine("HashCode for val1 = "+val1.GetHashCode()); Console.WriteLine("HashCode for val2 = "+val2.GetHashCode()); } }OutputThis will produce the following output −HashCode for val1 = 100 HashCode for val2 = 0ExampleLet us see another example − Live Demousing System; public class Demo { public static void Main() { uint val1 = 50; ... Read More

245 Views
Let us see an example to use foreach loop in arrays −Example Live Demousing System; public class Demo { public static void Main() { string[] products = new string[] { "Electronics", "Accessories", "Clothing", "Toys", "Clothing", "Furniture" }; Console.WriteLine("Products list..."); foreach(string s in products) { Console.WriteLine(s); } Console.WriteLine("Is the products Accessories in the array? = {0}", Array.Exists(products, ele => ele == "Accessories")); Console.WriteLine("Is the products Stationery in the array? = {0}", Array.Exists(products, ele => ele == "Stationery")); ... Read More

149 Views
To get the angle whose sine is float value argument, the code is as follows −Exampleusing System; public class Demo { public static void Main() { float val1 = 0.1f; float val2 = 8.9f; Console.WriteLine("Angle (val1) = "+(MathF.Asin(val1))); Console.WriteLine("Angle (val2) = "+(MathF.Asin(val2))); } }OutputThis will produce the following output −Angle (val1) = 0.1001674 Angle (val2) = NaNExampleLet us see another example −using System; public class Demo { public static void Main() { float val1 = 1.2f; float val2 = ... Read More

128 Views
To get the hyperbolic arc-cosine of a floating-point value, the code is as follows −Exampleusing System; public class Demo { public static void Main() { float val1 = 0.1f; float val2 = 0.9f; Console.WriteLine("Angle (val1) = "+(MathF.Acosh(val1))); Console.WriteLine("Angle (val2) = "+(MathF.Acosh(val2))); } }OutputThis will produce the following output −Angle (val1) = NaN Angle (val2) = NaNExampleLet us see another example −using System; public class Demo { public static void Main() { float val1 = 5.1f; float val2 = 8.9f; Console.WriteLine("Angle (val1) = "+(MathF.Acosh(val1))); Console.WriteLine("Angle (val2) = "+(MathF.Acosh(val2))); } }OutputThis will produce the following output −Angle (val1) = 2.312634 Angle (val2) = 2.876027