- 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 34489 Articles for Programming
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
86 Views
Set query in a select clause using the into operator.The following is our list with Employee details −IList employee = new List() { new Employee() { EmpID = 1, EmpName = "Tom", EmpMarks = 90, Rank = 8} , new Employee() { EmpID = 2, EmpName = "Anne", EmpMarks = 60, Rank = 21 } , new Employee() { EmpID = 3, EmpName = "Jack", EmpMarks = 76, Rank = 18 } , new Employee() { EmpID = 4, EmpName = "Amy" , EmpMarks = 67, Rank = 20} , };Now, fetch employee name that ends ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
3K+ Views
Use the Linq Average() method to find the average of a sequence of numeric values.Firstly, set a sequence.List list = new List { 5, 8, 13, 35, 67 };Now, use the Queryable Average() method to get the average.Queryable.Average(list.AsQueryable());Example Live Demousing System; using System.Linq; using System.Collections.Generic; class Demo { static void Main() { List list = new List { 5, 8, 13, 35, 67 }; double avg = Queryable.Average(list.AsQueryable()); Console.WriteLine("Average = "+avg); } }OutputAverage = 25.6
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
186 Views
Declare a LinkedList and add nodes to it.string [] students = {"Tim", "Jack", "Henry", "David", "Tom"}; LinkedList list = new LinkedList(students);Let us add a new node.var newNode = list.AddLast("Kevin");Now, to add a node before the given node, use the AddBefore() method.list.AddBefore(newNode, "Matt");Let us now see the complete code.Example Live Demousing System; using System.Collections.Generic; class Demo { static void Main() { string [] students = {"Tim", "Jack", "Henry", "David", "Tom"}; LinkedList list = new LinkedList(students); foreach (var stu in list) { Console.WriteLine(stu); } ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
186 Views
Set a LinkedList with nodes.string [] students = {"Tim", "Jack", "Henry", "David", "Tom"}; LinkedList list = new LinkedList(students);Now, use the AddLast() method to add a node at the last position.list.AddLast("Kevin");Here is the complete code with the updated LinkedList.Example Live Demousing System; using System.Collections.Generic; class Demo { static void Main() { string [] students = {"Tim", "Jack", "Henry", "David", "Tom"}; LinkedList list = new LinkedList(students); foreach (var stu in list) { Console.WriteLine(stu); } // adding a node at the end ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
2K+ Views
To implicitly convert char to a Decimal, firstly set a char.char c = 'p';To convert char to decimal, assign the value.decimal dec; dec = c;Let us see the above example.Example Live Demousing System; public class Demo { public static void Main() { char c = 'p'; decimal dec; Console.WriteLine("Implicit conversion from Char to Decimal"); dec = c; Console.WriteLine("Decimal : "+dec); } }OutputImplicit conversion from Char to Decimal Decimal : 112
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
161 Views
The short type represents a 16-bit signed integer i.e. Int16.To implicitly convert a 16-bit signed integer to a Decimal, firstly set a short value.short val = -32768;To convert short to decimal, assign the value.dec = val;Let us see another example.Example Live Demousing System; public class Demo { public static void Main() { short val = -32768; decimal dec; Console.WriteLine("Implicit conversion from Int16 to Decimal"); dec = val; Console.WriteLine("Decimal : "+dec); } }OutputImplicit conversion from Int16 to Decimal Decimal : -32768
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
585 Views
In a Linked List, if you want to add a node at the first position, use AddFirst method.Let’s first set a LinkedList.string [] students = {"Jenifer", "Angelina", "Vera"}; LinkedList list = new LinkedList(students);Now, to add an element as a first node, use AddFirst() method.List.AddFirst(“Natalie”);Example Live Demousing System; using System.Collections.Generic; class Demo { static void Main() { string [] students = {"Jenifer", "Angelina", "Vera"}; LinkedList list = new LinkedList(students); foreach (var stu in list) { Console.WriteLine(stu); } // add a node ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
5K+ Views
Use the Convert.ToInt32() method to convert a specified value to a 32-bit signed integer.Let us take a double variable.double doubleNum = 11.53;Now, we will convert it to Int32 using the Convert.ToInt32 method.int intNum; ntNum = Convert.ToInt32(doubleNum);Example Live Demousing System; public class Demo { public static void Main() { double doubleNum = 11.53; int intNum; intNum = Convert.ToInt32(doubleNum); Console.WriteLine("Converted {0} to {1}", doubleNum, intNum); } }OutputConverted 11.53 to 12
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
235 Views
To return a collection with repeated elements in C#, use Enumerable.Repeat method.It is part of System.Linq namespace.Let’s say you need to repeat a number twice, for that set the number and the frequency of repetition.Enumerable.Repeat(50, 2);Now assign it to a variable and display it.Example Live Demousing System; using System.Linq; class Demo { static void Main() { // repeating element 50, two times var num = Enumerable.Repeat(50, 2); // displayig repeating elements foreach (int ele in num) { Console.WriteLine(ele); } } }Output50 50
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
137 Views
Set a string.char[] ch = { 'd', 'r', 'i', 'v', 'e' }; Console.Write("String = foreach(char arr in ch) Console.Write(arr);Now, use Queryable Reverse() method to invert the order of elements.IQueryable res = ch.AsQueryable().Reverse();Let us see the complete code.Example Live Demousing System; using System.Linq; using System.Collections.Generic; public class Demo { public static void Main() { char[] ch = { 'd', 'r', 'i', 'v', 'e' }; Console.Write("String = "); foreach(char arr in ch) Console.Write(arr); IQueryable res = ch.AsQueryable().Reverse(); Console.Write("Reversed = "); foreach (char c in res) Console.Write(c); } }OutputString = drive Reversed = evird