- 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
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
302 Views
The ulong type represents a 64-bit unsigned integer i.e. UInt64.To implicitly convert a 64-bit unsigned integer to a Decimal, firstly set UInt64 value.ulong val = ulong.MaxValue;To convert ulong to decimal, assign the value.decimal dec; dec = val;Let us see the above example.Example Live Demousing System; public class Demo { public static void Main() { ulong val = ulong.MaxValue; decimal dec; Console.WriteLine("Implicit conversion from Ulong to Decimal"); dec = val; Console.WriteLine("Decimal : "+dec); } }OutputImplicit conversion from Ulong to Decimal Decimal : 18446744073709551615
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
596 Views
Use Convert.ToInt32 method to convert text to an integer.Firstly, set a string.string str = "12";Now, use the Convert.ToInt32() method the above string to number.Convert.ToInt32(str);Let us see the complete example.Example Live Demousing System; class Program { static void Main() { string str = "12"; Console.WriteLine("String: "+str); int n = Convert.ToInt32(str); Console.WriteLine("Number: "+n); } }OutputString: 12 Number: 12
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
56K+ Views
Convert a string representation of number to an integer, using the int.TryParse() method in C#. If the string cannot be converted, then the int.TryParse() method returns false i.e. a Boolean value.Let’s say you have a string representation of a number.string myStr = "12";Now to convert it to an integer, use the int.TryParse(). It will get converted and will return True.int.TryParse(myStr, out a);Example Live Demousing System.IO; using System; class Program { static void Main() { bool res; int a; string myStr = "12"; res = int.TryParse(myStr, out a); ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
85 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)
582 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