C#

C#- Programming Guide | Starting Phase Learning(3)

Other important terms contd.

  1. Common Language Runtime:
    It is a platform on which the .Net programs are executed.
  2. Class Library:
    Collection of Classes which includes methods, properties, and functions

C# Projects include different types of Applications:

  1. Windows Forms – Developing Forms-based applications
  2. Console Application: A simple command like application
  3. Class Library: Creating dll files
  4. Silverlight Application-Creating rich internet application
  5. WCF Service-Windows Communication Foundation (WCF) is a framework for building service-oriented applications. Using WCF, you can send data as asynchronous messages from one service endpoint to another.A service endpoint can be part of a continuously available service hosted by IIS, or it can be a service hosted in an application.
  6. ASP.Net – This is used for developing web-based applications. We can create by using Asp.NET, Asp.NET MVC, Asp.NET Web API and Angular 2 or above
  7. ADO.Net – To interact with Databases
  8. LINQ- To interact with Databases

3.NameSpace:
The container of different classes merged as one assembly. Once we declare the assembly we can import its abstract features.

using System;
using System.ComponentModel;
using System.Configuration;
using System.Threading;
using System.Web.Mvc;


** Download and Install Visual Studio for C#:
Visual Studio can be downloaded from the following link https://www.visualstudio.com/downloads/


After the installation, we will try to open a console project in Visual Studio

Steps to start with a console application Visual Studio.
Step1:Open Visual Studio

Visual Studio 2015
Open a project

Step 2:Create a new project.
Go to File menu > Select New >Project and then a pop up will appear.

List of projects view

Step 3:Create a new console project
A popup screen appears as below and then> Select C# >Choose Console Application from the list item present on the pop up >and then a give a project name for the application.
You can give any name for your project. The name entered should be at the highlighted section (Yellow color)

Choosing a console application

Step 4:This will bring you to below like screen. This is the place where we will do all the programming stuff.

Program Class

Building our first Program in C#:

Here, we will try to print a welcome text using a variable.
Code:

program.cs
Result(Output)

using System;
namespace TenOClocks
{
public class Program
{
static void Main(string[] args)
{
string _welcomeText = “Welcome to tenOclocks.com”;
Console.WriteLine(_welcomeText);
}
}
}

Explanation:
Here ,
using System – Its a name space (You have to include the namespace just like in c or C++ you include like #include<math.h>.
The System namespace contains fundamental classes and base classes that define commonly-used value and reference data types, events and event handlers, interfaces, attributes, and processing exceptions. (ref https://docs.microsoft.com/en-us/dotnet/api/system?view=netframework-4.8 )

To take the characteristics and features of that assembly/namespace we need to add the keyword “using“.

Public – fits access modifier (Gives protection to the class ), but since its public, therefore protection has gone public, means anyone can use the class
A more detailed discussion will be released in the later articles

Class -Just get an idea that we put all our stuff inside a class so that we can take its feature later.
static : Its means You do not need to instantiate its class to take the result
void : the return type is void
Program: You can give any name to it.
Main: Here, we access a string array called “args.” This array is populated with command-line arguments from the operating system. (you can know it later once we get into it)
string : data type (we have different data type like int , var , dynamic etc
_welcomeText :its a variable
Welcome to tenOclocks.com” : Its a string value
Console.WriteLine(_welcomeText): This is used to print the text
Console.ReadKey();: It holds the output screen, Once you try without including this statement. You will know it better.

So it quite easy to grab that
here, we want to display the message “Welcome to tenOclocks.com” on-screen, so we are storing the value in one variable which is of string type and then printing the value on the screen by using Console.WriteLine();

You also have Console.Write() to print anything;

Difference between WriteLine() and Write()

Like,
static void Main(string[] args)
{
string _welcomeText = “Welcome to tenOclocks.com”;
Console.WriteLine(_welcomeText);
Console.WriteLine(_welcomeText);
}
WriteLine() : print the statements in different line.
Output:
Welcome to tenOclocks.com
Welcome to tenOclocks.com

static void Main(string[] args)
{
string _welcomeText = “Welcome to tenOclocks.com”;
Console.Write(_welcomeText);
Console.Write(_welcomeText);
}
Write(): Prints in the same line
Output
Welcome to tenOclocks.comWelcome to tenOclocks.com

C#- Programming Guide | Beginner Phase Learning(2)



Ankit

Leave a Comment

View Comments

Recent Posts

The Rise of Corporate Event Companies in Mumbai

Mumbai, often referred to as the financial capital of India, is a hub for businesses and industries. With countless corporate…

3 weeks ago

The Ultimate Guide to Choosing the Best Security Company in Noida

When it comes to security services in Noida, there are several reputable companies that cater to various needs. Let me…

1 year ago

Steel Bite Pro: The Revolutionary Supplement Transforming Oral Health Forever

Are you tired of dealing with tooth decay, gum problems, and expensive dental treatments? Look no further! Steel Bite Pro…

1 year ago

Captivating Elegance: Unveiling the Beauty of Oval Moissanite Rings

In the world of fine jewelry, oval moissanite rings have emerged as a captivating choice for those seeking elegance and…

1 year ago

Top 10 Digital Marketing Agency In Noida

Noida, located in the state of Uttar Pradesh, is a fast-growing hub of digital marketing agencies in India. Choosing the…

2 years ago

Two-Wheeled Thrills: The Ultimate Guide to the Latest Bikes in India 2023

As we move into 2023, the world of motorcycles in India is set to see some exciting changes. Manufacturers are…

2 years ago