C#
C# is a Object Oriented Programming language which is created by Microsoft and runs on .NET framework. First version of C# is released in 2002.
C# is used for:
- Mobile applications
- Desktop applications
- Web applications
- Web services
- Web sites
- Games
- VR
- Database applications
- Distributed applications
- And much, much more!
C# programming language is influenced by C++, Java, Eiffel, Modula-3, Pascal etc. languages.
Built in types
Datatypes
Data Type |
Size |
Description |
int |
4 bytes |
Stores whole numbers from -2,147,483,648 to 2,147,483,647 |
long |
8
bytes |
Stores
whole numbers from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 |
float |
4 bytes |
Stores fractional numbers. Sufficient for storing 6 to 7 decimal
digits |
double |
8
bytes |
Stores
fractional numbers. Sufficient for storing 15 decimal digits |
bool |
1 bit |
Stores true or false values |
char |
2
bytes |
Stores
a single character/letter, surrounded by single quotes |
string |
2 bytes per character |
Stores a sequence of characters, surrounded by double quotes |
Printing statement
Input statement
Difference between Java and C#
No. |
Java |
C# |
1) |
Java
is a high level, robust, secured and object-oriented programming language
developed by Oracle. |
C# is
an object-oriented programming language developed by
Microsoft that runs on .Net Framework. |
2) |
Java
programming language is designed to be run on a Java platform, by the help
of Java Runtime Environment (JRE). |
C#
programming language is designed to be run on the Common Language
Runtime (CLR). |
3) |
Java
program extension is .java |
C#
program extension is .cs |
4) |
Java
type safety is safe. |
C#
type safety is unsafe. |
5) |
In
java, built-in data types that are passed by value are called primitive
types. |
In C#,
built-in data types that are passed by value are called simple types. |
6) |
Arrays
in Java are direct specialization of Object. |
Arrays
in C# are specialization of System. |
7) |
Java
does not support conditional compilation. |
C#
supports conditional compilation using preprocessor directives. |
8) |
Java
doesn't support goto statement. |
C#
supports goto statement. |
9) |
Java
doesn't support structures and unions. |
C#
supports structures and unions. |
10) |
Java
supports checked exception and unchecked exception. |
C#
supports unchecked exception. |
11) |
Printing
statement is System.out.Println(“ ”); |
Printing
statement is Console.WriteLine(“ “); |
12) |
Input
statement in java, we should first import the scanner statement and Scanner
object should be created |
Input
statement in C#, we should use Console.ReadLine(); |
Access modifiers
public
The type or member can be accessed by any other code in the same assembly or another assembly that references it. The accessibility level of public members of a type is controlled by the accessibility level of the type itself.
private
The type or member can be accessed only by code in the same class or struct.
protected
The type or member can be accessed only by code in the same class, or in a class that is derived from that class.
internal
The type or member can be accessed by any code in the same assembly, but not from another assembly. In other words, internal types or members can be accessed from code that is part of the same compilation.
protected internal
The type or member can be accessed by any code in the assembly in which it's declared, or from within a derived class in another assembly.
private protected
The type or member can be accessed by types derived from the class that are declared within its containing assembly.
No comments:
Post a Comment