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#:
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
}
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
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# 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
Some Common Types of data types used in C# are:
The detailed analysis of data types will be discussed in the intermediate phase of C# learning.
When it comes to security services in Noida, there are several reputable companies that cater to various needs. Let me…
Are you tired of dealing with tooth decay, gum problems, and expensive dental treatments? Look no further! Steel Bite Pro…
In the world of fine jewelry, oval moissanite rings have emerged as a captivating choice for those seeking elegance and…
Noida, located in the state of Uttar Pradesh, is a fast-growing hub of digital marketing agencies in India. Choosing the…
As we move into 2023, the world of motorcycles in India is set to see some exciting changes. Manufacturers are…
The Indian Premier League (IPL) is one of the most popular and exciting cricket tournaments in the world. With the…
Leave a Comment