C#-Basics

C sharp or written n as C#

The basics of C# languag.

As in any standard language you do need to import libraries where the basic functions of the language are defined.Other wise you cannot start programming.

In Java you might be familiar with:import java.io.

Import is the key word to call libraries in Java.

In C# you do that by the keyword :Using.Then you write Library name followed by fullstop or delimiter that is semi colon ;.If you are familiar with C you will recall this practice.

Using System;

Basic Input and Out Put.

To do something really interesting you need input and Out Put.

In C# taking input is by following way:

Console.ReadLine();

Readline is followed by a bracket that denotes function.This was made clear if you do start with C++ or Java.

OutPut:

Console.Write();

Console.WriteLine():.

We can take input &output either by Console(black screen) or forms.

More like Java’s :System.in.

Now we know the input and out put in C#.

The data types in C# .

  • Char
  • int
  • Double
  • String

There are many types of data types.Here is link for the details .

Next we learn about functions and methods.

A function is part of OOP classes unlike other languages.If you already have done C++ and Java then you already are familiar.There are some difference.

The function in C#

public void SayHello()

{

Console.WriteLine(“Techventura is a techblog”);

}

Above function is named SayHello followed by brackets.Then there is key word called void meaning no return types.In Java it would have been called a method.

public int MyAge()

{

return 35;

}

Here above code returns an integer number and this is wht we have int preceding the function name.Pls notice this is very similar to Java with slight difference.

The main() Method in C#.

There is one Main method in any c# application in case there are others you have specify at compile time.(services and library).

.The Main() method is the first method to be invoked.

static void Main()

{

System.Console.WriteLine(“Welcome to .NET”);

}

.

Reference sites:

https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/main-and-command-args/

https://www.tutorialspoint.com/csharp/csharp_data_types.htm

Our Score
Our Reader Score
[Total: 1 Average: 5]

Leave a Reply

Your email address will not be published. Required fields are marked *