Post Page Advertisement [Top]



Click here to send WhatsApp On Unsaved Mobile Numbers For Free

Comments in Dart Programming Language
Comments in Dart Programming Language


Types of comments in Dart programming language.


There are three types of comments in the Dart programming language.


i) In-line Comments (//In-line comment)
ii) Block Comments or Multi-line Comments (/* Block comment */)
iii) Documentation Comments (/// Documentation comment)
-
-

What is Comment in a programming language?


The comment is a process of writing some hints about the code with the program. The comments in the program will be ignored by the compiler at the compile time. If a developer comments any text as well as any line of code, the compiler ignores at the commented line at the time of compilation and executes the program result. In different types of programming languages, there are different ways to do the comments.

In-line Comment:


The In-line comment is used to comment on the comment on a single line. The line may be a plain text or a piece of code. The double forward-slash (//) is used to in-line comment.

Example:
void main(){
    // program to print "Hello World!!!" in Dart programming language
    print("Hello World!!!");
}

Output:
Hello World!!!
-
-

Block Comment:


Block comment is used to comment on more than one line i.e, multiple lines. It is also known as a Multi-line comment. The multiple lines may be plain texts or codes. The multi-line comment starts with a forward slash followed by asterisk symbol /* and ends with asterisk symbol followed by a forward slash */.

Example:
import 'dart:core';

void main(){
 
    /* All build-in Libraries, Collections, Data Types, etc. are defined in the package of "dart:core". By default, the "dart:core" package is imported in every Dart program. The "dart:core" package is automatically even if the developers did not call it in the program. */

    // Write a Dart program to print your name.

    print("Rohit Kumar");

}

Output:
Rohit Kumar


Documentation Comment:


Documentation comment is also a type of comment in Dart programming language. Documentation comment is also used to comment on the plain texts or codes. Document comment is used to make brief documentation of the code in the program. Documentation comment is done by typing three forward slashes (///) in the program.

Example:
import 'dart:io';

void main(){

    /// Write a program to take input from user in Dart programming language.
    /// To take input from user we have to import a new package i.e, "dart:io" package.
    /// "dart:io" package contains everything that is used to take input from the user.

    stdout.writeln("What is your name? ");
    String name = stdin.readLineSync();
    print("My name is $name");

}

Output:
What is your name? Rohit Kumar
Rohit Kumar
Comments in Dart Programming Language.
Dart
-
-
---
I hope you likable this nice post. Do not forget to share it together with your friends, the Sharing Button is below the post. Apart from this, if there's any downside within the intermediate, don't hesitate to request the Comment Box. we are going to be happy to help you.

I will continue to write more and more on this blog, so do not forget to make our blog BlogLearner as a bookmark (Ctrl + D) on your mobile or computer and subscribe to us to get all the posts in your email. Do not forget to share these posts, if you like it. You can facilitate us reach additional individuals by sharing it on social networking sites like Facebook or Twitter.
Comments in Dart Programming Language.
Dart Programming Language
#dart #dart_programming_language #comments_in_dart_programming_language #rrkksinha #bloglearner

No comments:

Post a Comment

Bottom Ad [Post Page]

rrkksinha.