.Exe .DLL
.Exe .DLL
.NET Framework:
The .NET Framework consists primarily of a gigantic library of code that you use from your client languages (such as C#) using object-oriented programming (OOP) techniques. Part of the .NET Framework library defines some basic types. This is called the Common Type System (CTS). .Net Framework also includes the .NET Common Language Runtime (CLR), which is responsible for maintaining the execution of all applications developed using the .NET library.
Assemblies:
When you compile an application, the CIL code created is stored in an assembly. Assemblies include both executable application files that you can run directly from Windows without the need for any other programs (these have a .exe file extension) and libraries (which have a .dll extension) for use by other applications.
Managed Code:
The role of the CLR doesnt end after you have compiled your code to CIL and a JIT compiler has compiled that to native code. Code written using the .NET Framework is managed when it is executed (a stage usually referred to as runtime). This means that the CLR looks after your applications by managing memory, handling security, allowing cross -language debugging, and so on.
Garbage Collection:
One of the most important features of managed code is the concept of garbage collection. This is the .NET method of making sure that the memory used by an application is freed up completely when the application is no longer in use.
Linking:
The C# code that compiles into CIL neednt be contained in a single file. Its possible to split application code across multiple source code files, which are then compiled together into a single assembly. This extremely useful process is known as linking.
namespace ConsoleApplication1 { class Program { static void Main(string[] args) { // Output text to the screen. Console.WriteLine("The first app in Beginning C# Programming!"); Console.ReadKey(); } } }
C# syntax for declaring variables merely specifies the type and variable name:
<type> <name>;
Simple Types:
Unlike complex types, simple types cannot have children or attributes. A number of different integer types can be used to store various ranges of numbers, which take up differing amounts of memory (up to 64 bits).
Three floating-point variable types: float , double , and decimal . The first two store floating points in the form +/ m 2e , where the allowed values for m and e differ for each type. decimal uses the alternative form +/ m 10 e .
static void Main(string[] args) { int myInteger; string myString; myInteger = 17; myString = "\"myInteger\" is"; Console.WriteLine("{0} {1}.", myString, myInteger); Console.ReadKey(); // Output // Assignment // Declaration
placeholders
}
When the text is output to the console, each placeholder is replaced by the corresponding value for each variable. In the preceding example, the {0} is replaced with the actual value of the first variable, myString, and {1} is replaced with the contents of myInteger.
Variable Naming:
The basic variable naming rules are as follows:
The first character of a variable name must be either a letter, an und erscore character ( _ ), or
There are also certain keywords that have a specialized meaning to the C# compiler, such as
the using and namespace keywords shown earlier. Currently, two naming conventions are used in the .NET Framework namespaces: PascalCase and camelCase The following are camelCase variable names:
age firstName timeOfDeath
Microsoft recommendation:
yet_another_variable .
String Literals:
You can specify any Unicode character using a Unicode escape sequence. These consist of the standard \ character followed by a u and a four-digit hexadecimal value (for example, the four digits after the x in the preceding table). This means that the following strings are equivalent:
"Karli\s string." "Karli\u0027s string."
You can also specify strings verbatim. The only exception to this is the escape sequence for the double quotation mark character, which must be specified to avoid ending the string. To do this, place the @ character before the string:
@"Verbatim string literal."
Verbatim strings are particularly useful in filenames, as these use plenty of backslash characters. Using normal strings, youd have to use double backslashes all the way along the string:
"C:\\Temp\\MyDir\\MyFile.doc"
With verbatim string literals you can make this more readable. The following verbatim st ring is equivalent to the preceding one:
@"C:\Temp\MyDir\MyFile.doc"
Results in only ySize being initialized xSize is just declared, and it still needs to be initialized before its used.
EXPRESSIONS:
Operators can be roughly classified into three categories:
Unary Act on single operands BinaryAct on two operands TernaryAct on three operands
Example
class Program { static void Main(string[] args) { double firstNumber, secondNumber; string userName; Console.WriteLine("Enter your name:"); userName = Console.ReadLine(); Console.WriteLine("Welcome {0}!", userName); Console.WriteLine("Now give me a number:"); firstNumber = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("Now give me another number:"); secondNumber = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("The sum of {0} and {1} is {2}.", firstNumber, secondNumber, firstNumber + secondNumber); Console.WriteLine("The result of subtracting {0} from {1} is {2}." , secondNumber, firstNumber, firstNumber - secondNumber); Console.WriteLine("The product of {0} and {1} is {2}.", firstNumber, secondNumber, firstNumber * secondNumber); Console.WriteLine("The result of dividing {0} by {1} is {2}.", firstNumber, secondNumber, firstNumber / secondNumber); Console.WriteLine("The remainder after dividing {0} by {1} is {2}.", firstNumber, secondNumber, firstNumber % secondNumber); Console.ReadKey(); } }