- 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
Chandu yadav has Published 1163 Articles
Chandu yadav
168 Views
To get all the disk drives on a system, use the GetLogicalDrives() method in C# −Environment.GetLogicalDrives()Use it with Join method to get the comma-separated list of logical drives −string.Join(", ", Environment.GetLogicalDrives())Example Live Demousing System; using System.IO; namespace Demo { class Program { static void Main(string[] args) { ... Read More
Chandu yadav
439 Views
Use the Regex.Replace method to remove the end part of a string in C#.The following is the string −string s1 = "Demo Text!";Now, let us say you need to remove the exclamation mark (!) from the string. For that just set it to empty using replace −System.Text.RegularExpressions.Regex.Replace(s1, "!", "");Here is ... Read More
Chandu yadav
2K+ Views
Firstly, set a string −string str = "Science and Mathematics";Now use the Split() method to split wherever the spaces occur −str.Split(' ')The following is the complete code −Example Live Demousing System; using System.Linq; using System.IO; class Program { static void Main() { string str = "Science and ... Read More
Chandu yadav
66 Views
With C#, you can easily set a 6-item tuple.The following is a 6-item tuple −var myTuple = new Tuple("electronics", new string[] { "shoes", "clothing#", "accessories" }, 100, 250, 500, 1000);above, we have tuple for string, string array and int as shown below −TupleHere is the complete code −Example Live Demousing System; ... Read More
Chandu yadav
93 Views
It is quite possible to add multiple stored generated columns in a MySQL table. It can be illustrated with the following example as follows −Examplemysql> Create table profit1(cost int, price int, profit int AS (price-cost) STORED, price_revised int AS (price-2) STORED); Query OK, 0 rows affected (0.36 sec) mysql> ... Read More
Chandu yadav
238 Views
The All() extension method is part of the System.Linq namepspace. Using this method, you can check whether all the elements match a certain condition or not.Set an array −int[] arr = { 6, 7, 15, 40, 55 };The following is an example. It checks whether all the elements in the ... Read More
Chandu yadav
437 Views
The KeyNotFoundException is thrown when a key you are finding is not available in the Dictionary collection.Let us see an example −Example Live Demousing System; using System.Collections.Generic; public class Demo { public static void Main() { try { var dict = new Dictionary() ... Read More
Chandu yadav
1K+ Views
To display the last three elements from a list, use the Take() method. For reversing it, use the Reverse() method.Firstly, declare a list and add elements to it −List myList = new List(); myList.Add("One"); myList.Add("Two"); myList.Add("Three"); myList.Add("Four");Now, use the Take() method with Reverse() to display the last three elements from ... Read More
Chandu yadav
99 Views
Set a DateTime object;DateTime dt = DateTime.Now;To get years in different formats, try the following −dt.ToString("yy") dt.ToString("yyy") dt.ToString("yyyy") dt.ToString("yyyyy")Here is the complete code −Example Live Demousing System; using System.Threading; using System.Diagnostics; public class Demo { public static void Main() { DateTime dt = DateTime.Now; ... Read More
Chandu yadav
12K+ Views
To convert a string to a long, use the Long.parse method in C# −Firstly, set a string −string str = "6987646475767";Now, convert it to long −long.Parse(str);Here is the complete code −Example Live Demousing System; using System.Linq; class Demo { static void Main() { string str = "6987646475767"; ... Read More