C# - Value type and reference type

C# is language which operates with two kind of types: value type - type where only one space of memory is allocated. It is related for primitive C# types like: int, char, float, bool etc. as well as for struct types. If you copy value type to another type new instance of object will be created. reference type - type related to class objects. When we are declaring such class object, two memory spaces are...
Read more »

C# - Calling one constructor from another

In order to call one constructor from another constructor in C# programming language you can use below syntax: class Plane {  Plane (){}  Plane (int a) : this() {}  Plane (int a, int b) : this(int a) {} } In above example constructor Plane (int a) invokes parameterless constructor Plane(). Constructor Plane(int a, int b) invoke two above constructors nested. ...
Read more »

C# - Enumerations and bit fields

Enumeration is basic C# type mostly used for increase readability of code and make variable type safety. Assume that we would like to use weekdays in some variable. We can create create int variable for it and assume that following numers (1-7) are associated with following weekdays. This would be enough but every user which will read our code should know about our assumptions to have no problems with analyze. Additionally...
Read more »

C# - Protection of field modification

C# provide two field modifiers for protection of field modification. Except of const keyword well-known from C++ we have additional readonly keyword in C#. So we have three levels of field modification protection in C#: private bool fieldName - such field cannot be modify outside class but can be modify inside private readonly bool fieldName - such field can be modified in constructor of class only (useful for variables which...
Read more »

C# - Field and Property difference

Instead of classic class field definition, C# adds one more class element - property. Sometimes there is hard to understand difference between field and property in C# for beginners.  Main difference is:  Field is just simple variable within class, while property is field wrapped in two functions: getter and setter. So in general, if you define property, compiler silently creates invisible field for that property make...
Read more »

C# - Protection Levels

Because C# is object oriented programming language its class implementation allows using encapsulation mechanism.  Encapsulation is mechanism which allow hide some functionality within class or object to avoid its access from outside of that class or object.   Encapsulation is very useful in order to make protection for some operation and make them invoke in only one known place of code. Thanks to that we have...
Read more »

C# - Assembly unit

C# defines new translation unit of application composition called assembly unit. Microsoft MSDN website defines assembly unit in following way: Assemblies form the fundamental unit of deployment, version control, reuse, activation scoping, and security permissions for a .NET-based application. Assemblies take the form of an executable (.exe) file or dynamic link library (.dll) file, and are the building...
Read more »

C# - PascalCasting vs camelCasting

PascalCasting vs camelCasting - types of naming function or variables names.  PascalCasting - naming when we starts with capital letter and each next word start with capital letter. Used for properties, methods, types  camelCasting - naming when we starts with lower case letter and each next word start with capital letter. Used for parameters, fields, variables...
Read more »

C# - XML Documentation Comments

C# allows create create XML-styled comments which are used by Visual Studio to create tooltips with information about function. XML-styled commets starts with /// characters. When you put /// characters above particular function definition Visual Studio will generate you template of XML-styled comments for that function. See below image as example of XML-styled comments and effect of those comments on toolkit. ...
Read more »

C# - basic definitions

Today I will present few basic definitions related to C# and .NET Framework environment. If you will develop some code in C# and .NET you will definitely meet those definitions. Common Language Runtime (CLR) - it is virtual machine component used in .NET Framework (similar to JVM). It is responsible for managing and execution of .NET programs. Its main task is converting Intermediate Language...
Read more »

C# basics - Difference between float, double and decimal

decimal values has better precision and should be used for financial operation but work slower than double, so double values should be used when performance is priority. In general, c# floating points have following precisions: float - 7 digits double - 15-16 digits decimal - 28-29 digits See below example: Output of that example is as follows: As you can see output output of conditions for...
Read more »

Welcome C# and .NET lovers

Welcome all C# and .NET framework lovers. I am starting this blog to share my C# adventure with you. I will try to explain here usage of some C# features as well as I will describe my experience with working as C# developer. I hope you will find a lot of useful informations here. All comments are welcome.Let's start our common C# adventure. Hello world :) ...
Read more »
Powered by Blogger.

Sample Text

Sample Text

Sample text

Sample Text

Social Icons

Social Icons

Followers

Featured Posts