
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

696 Views
In C#, a structure is a value type data type. It helps you to make a single variable hold related data of various data types. The struct keyword is used for creating a structure.When you define a class, you define a blueprint for a data type.The following are the differences between classes and structures in C# −Classes are reference types and structs are value typesUnlike classes, structures cannot inherit other structures or classes.Structures cannot be used as a base for other structures or classes.When you create a struct object using the New operator, it gets created and the appropriate constructor ... Read More

3K+ Views
To compare strings in C#, use the compare() method. It compares two strings and returns the following integer values −If str1 is less than str2, it returns -1. If str1 is equal to str2, it returns 0. If str1 is greater than str2, it returns 1.Set the two strings in the String.compare() method and compare them −string.Compare(string1, string2);ExampleYou can try to run the following code to compare two strings in C#.Live Demousing System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Demo { class MyApplication { static void Main(string[] args) { ... Read More

6K+ Views
Common Language Runtime (CLR) manages the execution of .NET programs. The just-in-time compiler converts the compiled code into machine instructions. This is what the computer executes.The services provided by CLR include memory management, exception handling, type safety, etc.Let us see the features of Common Language Runtime (CLR) in C#:ComponentsComponents in other languages can be easily worked upon with CLR.ThreadingThe CLR provides support for threads to create multithreaded applications.Class Library SupportIt has built-in types and libraries for assemblies, threading, memory management, etc.DebuggingCLR makes code debugging easier.Garbage CollectionIt provides automatic garbage collection in C#.

359 Views
Let’s say we have set the number for which we will find the sum of digits −int val = 789; Console.WriteLine("Number:", val);The following will find the sum of digits by entering the number and checking it recursively −public int addFunc(int val) { if (val != 0) { return (val % 10 + addFunc(val / 10)); } else { return 0; } }ExampleThe following is our code to find the sum of digits of a number using Recursion in C#.Live Demousing System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Demo { ... Read More

7K+ Views
If the remainder of the number when it is divided by 2 is 0, then it would be divisible by 2.Let’s say our number is 5, we will check it using the following if-else −// checking if the number is divisible by 2 or not if (num % 2 == 0) { Console.WriteLine("Divisible by 2 "); } else { Console.WriteLine("Not divisible by 2"); }ExampleThe following is an example to find whether the number is divisible by 2 or not.Live Demousing System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Demo { class MyApplication { static ... Read More

558 Views
To create a thread, I have created a function −public void myThread() { for (int i = 0; i < 3; i++) { Console.WriteLine("My Thread"); } }The above function is called to create a thread and a new ThreadStart delegate is created −Demo d = new Demo(); Thread thread = new Thread(new ThreadStart(d.myThread));ExampleCreate a simple thread using the following code.Live Demousing System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; class Demo { public void myThread() { for (int i = 0; i < 3; i++) { ... Read More

14K+ Views
Firstly, let’s set the three numbers −int num1, num2, num3; // set the value of the three numbers num1 = 10; num2 = 20; num3 = 50;Now check the first number with the second number. If num1 > num2, then check num1 with num3. If num1 is greater than num3, that would mean the largest number is num1.ExampleYou can try to run the following code to find the maximum of three numbers.Live Demousing System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Demo { class MyApplication { static void Main(string[] args) { int ... Read More

3K+ Views
To split and join a string in C#, use the split() and join() method. Let us say the following is our string −string str = "This is our Demo String";To split the string, we will use the split() method −var arr = str.Split(' ');Now to join, use the join() method and join rest of the string. Here, we have skipped the part of the string using the skip() method −string rest = string.Join(" ", arr.Skip(1));ExampleYou can try to run the following code in C# to split and join a string.Live Demousing System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Demo ... Read More

8K+ Views
Firstly, set the Celsius temperature −double celsius = 36; Console.WriteLine("Celsius: " + celsius);Now convert it into Fahrenheit:fahrenheit = (celsius * 9) / 5 + 32;You can try to run the following code to convert Celsius to Fahrenheit.ExampleLive Demousing System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Demo { class MyApplication { static void Main(string[] args) { double fahrenheit; double celsius = 36; Console.WriteLine("Celsius: " + celsius); fahrenheit = (celsius * 9) / 5 + 32; Console.WriteLine("Fahrenheit: " + fahrenheit); Console.ReadLine(); } } }OutputCelsius: 36 Fahrenheit: 96.8