C#

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

Comments and region in C#:

Here we will learn about making the code effective by adding comments and region in c#.
There are different types of comments used in c#:

  1. Single-line comments
  2. Multi-line Comments

Its very useful and professional to use comments before adding any menthods or class so that teh other coders are aware of your code and its associated functions

Single-line comments:
It starts with two forward slashes i.e //
The text following with // is ignored by C# (it wont be executed or debugged).

// This is a single line comment
Console.WriteLine(“Hello tenOclocks!”);

or
Console.WriteLine(“Hello tenOclocks!”);//This is used to print the message

or,
// This is a function to print a message
public void GetMessage()
{
Console.WriteLine(“Hello tenOclocks!”);
}

Multi-line comments start with /* and ends with /. So any texts written between / and */ will be ignored by C#.

/* The function will print the message
to the screen*/
public void GetMessage()
{
Console.WriteLine(“Hello tenOclocks!”);
}

So Seeing both single line and multi line comments under one sample program,
/* Multi
Line
Comment*/
public void GetMessage()
{
Console.WriteLine(“Hello tenOclocks!”); //Single line comment
}

#region

Whenever we write the piece of code under # region, then we define a region that lets you specify a block of code that can be expanded or collapsed using the outlining feature of the Visual Studio Code Editor.
In longer code files, it is convenient to be able to collapse or hide one or more regions so that you can focus on the part of the file that you are currently working on.
A #region block must be terminated with a #endregion directive.

    #region This block gets the welcome text
    /* Multi
       Line 
       Comment*/    public void GetMessage()
    {
        Console.WriteLine("Hello tenOclocks!"); //Single line comment
    }
    #endregion

DataType and Variables:

string s = “tenOclocks”;
string s1= “tenOclocks”;
string s2= “tenOclocks”;
string _text= “tenOclocks”;
string c_text = “tenOclocks”;


Here, string is a data type and (s , s1 , s2 , _text , c_text ) are variables .
So in an easy language, a variable is a name that we give to a certain dataType.
While coming to the definition it is a named memory location of data type which is used to store data. Its value can be changed and reused many times.

C# | Data Types :

C# is a strongly typed programming language because here, each type of data is predefined as part of the programming language.All then the constants a;nd variables should have their associated data type.

Data types in C# is mainly divided into three categories

  1. Value Data Types
  2. Reference Data Types
  3. Pointer Data Type
Types of DataType in C#

Some Common Types of data types used in C# are:

  1. char : 1 byte -used to assign a single character under ‘ ‘, the default value ‘\0’
  2. short : 2 byte -Stores an integer value, default value 0
  3. int : 4 byte -Stores an integer value , default value 0
  4. long : 8 byte -Stores larger integer value , default value 0
  5. float : 4 byte -Stores larger float type value , default value 0.0F
  6. double: 8 byte -Stores a higher float value , default value 0.0D
  7. decimal: 16 byte – 128-bit precise decimal values with 28-29 significant digits, default value: 0.0M


The detailed analysis of data types will be discussed in the intermediate phase of C# learning.


tenocloc

Leave a Comment

Recent Posts

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

Five new rules will change the game in IPL 2023

The Indian Premier League (IPL) is one of the most popular and exciting cricket tournaments in the world. With the…

2 years ago