- 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
Samual Sam has Published 2492 Articles
Samual Sam
2K+ Views
Set the listvar val = new int[] { 99, 35, 26, 87 };Now get the largest number.val.Max(z => z);Smallest numberval.Min(z => z);Second largest numberval.OrderByDescending(z => z).Skip(1).First();Second smallest numberval.OrderBy(z => z).Skip(1).First();The following is the code −Example Live Demousing System; using System.Linq; public class Program { public ... Read More
Samual Sam
2K+ Views
Abstraction and encapsulation are related features in object-oriented programming. Abstraction allows making relevant information visible and encapsulation enables a programmer to implement the desired level of abstraction.Abstraction can be achieved using abstract classes in C#. C# allows you to create abstract classes that are used to provide a partial class ... Read More
Samual Sam
668 Views
To print duplicates from a list of integers, use the ContainsKey.Below, we have first set the integers.int[] arr = { 3, 6, 3, 8, 9, 2, 2 };Then Dictionary collection is used to get the count of duplicate integers.Let us see the code ... Read More
Samual Sam
75 Views
To find the difference between two dates in C#, you need to first set two dates to be compared using the DateTime object. We will use the DateTime class in C#.Date 1DateTime date1 = new DateTime(2018, 09, 15); Console.WriteLine("Date 1 : {0}", date1);Date 2DateTime date2 = new DateTime(2018, 09, 28); ... Read More
Samual Sam
242 Views
With C#, you can easily display the following diamond shape.$ $$$ $$$$$ $$$$$$$ $$$$$$$$$ $$$$$$$ $$$$$ $$$ $To display a diamond shape, you need to focus on the following points −Number of rows Dollar sign to be displayed Empty spacesConsidering the above you can easily create the diamond shape as ... Read More
Samual Sam
15K+ Views
Use the Contains() method to check if a string contains a word or not.Set the string −string s = "Together we can do so much!";Now let’s say you need to find the word “much”if (s.Contains("much") == true) { Console.WriteLine("Word found!"); }Let us see the complete code −Example Live Demousing System; ... Read More
Samual Sam
1K+ Views
Declare a new ArrayList and add elements to it.ArrayList arr = new ArrayList(); arr.Add( "One" ); arr.Add( "Two" ); arr.Add( "Three" ); arr.Add( "Four" );Now let’s say you need to remove the element “Three”. For that, use the Remove() method.arr.Remove("Three");The following is the complete example to remove an element from ... Read More
Samual Sam
338 Views
Firstly, set the first two numbers −double val1, val2; val1 = 10; val2 = 5;Now use the Math.Sqrt function to use Pythagoras Theorem.res = Math.Sqrt(val1 * val1 + val2 * val2);Example Live Demousing System; public class Program { public static void Main(string[] args) { double val1, val2, ... Read More
Samual Sam
1K+ Views
The ReadLine() method is used to read a line from the console in C#.str = Console.ReadLine();The above will set the line in the variable str.Example Live Demousing System; using System.Collections.Generic; class Demo { static void Main() { string str; // use ReadLine() ... Read More
Samual Sam
12K+ Views
To remove an item from a list in C# using index, use the RemoveAt() method.Firstly, set the list −List list1 = new List() { "Hanks", "Lawrence", "Beckham", "Cooper", };Now remove the element at 2nd position i.e. index 1list1.RemoveAt(1);Let us see the complete example −Example Live Demousing System; ... Read More