C#-ASP.NET, CORE
C#-ASP.NET, CORE
o Window applications
o Web applications
o Distributed applications
o Web service applications
o Database applications etc.
Java vs C#
There are many differences and similarities between Java and C#. A list of
top differences between Java and C# are given below:
No Java C#
.
4) In java, built-in data types that are In C#, built-in data types that are
passed by value are called primitive passed by value are called simple
types. types.
C# Data Types
A data type specifies the type of data that a variable can store such as
integer, floating, character etc.
decimal 16 byte at least -7.9 * 10?28 - 7.9 * 1028, with at least 28-digit
precision
Let's see the value data types. It size is given according to 32 bit OS.
AD
1. using System;
2. public class IfExample
3. {
4. public static void Main(string[] args)
5. {
6. Console.WriteLine("Enter a number:");
7. int num = Convert.ToInt32(Console.ReadLine());
8.
9. if (num % 2 == 0)
10. {
11. Console.WriteLine("It is even number");
12. }
13. else
14. {
15. Console.WriteLine("It is odd number");
16. }
17.
18. }
19. }
Output:
Enter a number:11
It is odd number
Output:
Enter a number:12
It is even number
C# If else-if Example
1. using System;
2. public class IfExample
3. {
4. public static void Main(string[] args)
5. {
6. Console.WriteLine("Enter a number to check grade:");
7. int num = Convert.ToInt32(Console.ReadLine());
8.
9. if (num <0 || num >100)
10. {
11. Console.WriteLine("wrong number");
12. }
13. else if(num >= 0 && num < 50){
14. Console.WriteLine("Fail");
15. }
16. else if (num >= 50 && num < 60)
17. {
18. Console.WriteLine("D Grade");
19. }
20. else if (num >= 60 && num < 70)
21. {
22. Console.WriteLine("C Grade");
23. }
24. else if (num >= 70 && num < 80)
25. {
26. Console.WriteLine("B Grade");
27. }
28. else if (num >= 80 && num < 90)
29. {
30. Console.WriteLine("A Grade");
31. }
32. else if (num >= 90 && num <= 100)
33. {
34. Console.WriteLine("A+ Grade");
35. }
36. }
37. }
Output:
Output: