Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts

Wednesday, October 28, 2015

How to create threads in C# ?

Threads can be created like other objects in C# using the 'new' keyword.
Thread th = new Thread(Write);
Thread class is available in System.Threading namespace.
We can start a thread using Start() method like.
th.Start();

Sunday, October 11, 2015

What are threads (multi-threading) in C# ?

Threads are the independent units of execution and can run simultaneously with other threads. Threads helps in achieving parallel execution in C#, which is also called multithreading.
A C# program typically starts with a single thread create automatically by CLR (Common Language Runtime) and operating system. If needed, additional threads has to be created manually through code.

Saturday, October 10, 2015

How to measure execution speed (time) in Milliseconds, Microseconds and Nanoseconds using Stopwatch in C# ?

There are situations in the programming world where developers need to measure the execution time of the code.
.NET framework provides Stopwatch class to measure elapsed time for an interval which has two properties ElapsedMilliseconds and ElapsedTicks.

Sunday, October 4, 2015

What is difference between DateTime.Now and DateTime.UtcNow ?

DateTime.Now is a built in property provided by .NET framework which returns the current time of the machine which is executing the code.
This property internally converts the DateTime.UtcNow provided value to the date and time format of the machine executing the code. Hence this property has an overhead of execution, so must be used carefully.

Sunday, May 3, 2015

What are Classes in C# ?

Classes are the blueprints for objects. Everything in C# is based upon classes.
A class normally consists of Methods, Fields and Properties. Classes are declared by using the keyword "class" followed by the class name and a set of class members surrounded by curly braces.

What is Object-Oriented Programming ?

Object-oriented programming (OOP) is a programming language model organized around "OBJECTS" instead of "actions" and data rather than logic. In procedural programming language, a program has been viewed as a logical procedure that takes input data, processes it, and produces output data.

Saturday, May 2, 2015

What is C# programming language ?

C# (pronounced as "see sharp") is an object-oriented programming (OOP) language created by Microsoft team which is led by Anders Hejlsberg. It is part of .Net family from Microsoft. C# is a language derived from C and C++, including features which made the language easy to use.