What are the types of comment in C# with examples?
Princy Gupta
There are 3 different types of comments in c#.(A) Single Line CommentsEx.. // use for single line comments in C#.(B) Multi Line CommentsEx. /* use multi line comments in c#*/(C) XML tags CommentsEx. /// use to specify the XML comments in c#Note - we can use Ctrl+K, Ctrl+C and Ctrl+K, Ctrl+U to Comment or Uncomment selected lines in C#.
Single lineEg: //This is a Single line commentMultiple line (/* */)Eg: /*descriptiontest1test2*/XML Comments (///).Eg /// /// description///
BALusing System; using System.Collections.Generic; using System.Linq; using System.Text; using DAL; using System.Data; namespace BAL {public class DataAcess{Connection objcon = new Connection();public object SelectCategory(){return objcon.SelectCategory();}public DataTable getdata(){return objcon.getdata();}public DataTable getdata1(string name){return objcon.getdata1(name);}public DataTable getdata2(string sal){return objcon.getdata2(sal);}public DataTable getdata3(string fromdate,string todate){return objcon.getdata3(fromdate,todate);}} }DALusing System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; using System.Configuration;namespace DAL {public class Connection{SqlConnection con = new SqlConnection("Data Source=TUSHAR-PC;Initial Catalog=mm;Integrated Security=True");// private string conn = ConfigurationManager.ConnectionStrings["Mythreetier"].ToString();public object SelectCategory(){con.Open();SqlCommand cmd = new SqlCommand("SELECT emplyee.*, deparment.*, salry.* FROM deparment INNER JOIN emplyee ON deparment.DId = emplyee.EmpID INNER JOIN salry ON deparment.DId = salry.salID", con);SqlDataAdapter da = new SqlDataAdapter(cmd);DataTable dt = new DataTable();da.Fill(dt);return dt;}public DataTable getdata(){con.Open();SqlCommand cmd = new SqlCommand("sp_getdata", con);cmd.CommandType = CommandType.StoredProcedure;SqlDataAdapter sda = new SqlDataAdapter(cmd);DataTable dt = new DataTable();sda.Fill(dt);return dt;}public DataTable getdata1(string name){SqlCommand cmd = new SqlCommand("GET_NAME", con);cmd.CommandType = CommandType.StoredProcedure;cmd.Parameters.AddWithValue("@name", name);SqlDataAdapter sda = new SqlDataAdapter(cmd);{DataTable dt = new DataTable();sda.Fill(dt);return dt;}}public DataTable getdata2(string sal){SqlCommand cmd = new SqlCommand("GET_SAL", con);cmd.CommandType = CommandType.StoredProcedure;cmd.Parameters.AddWithValue("@sal", sal);SqlDataAdapter sda = new SqlDataAdapter(cmd);{DataTable dt = new DataTable();sda.Fill(dt);return dt;}}public DataTable getdata3(string fromdate, string todate){SqlCommand cmd = new SqlCommand("GET_DATE", con);cmd.CommandType = CommandType.StoredProcedure;cmd.Parameters.AddWithValue("@fromdate", fromdate);cmd.Parameters.AddWithValue("@todate", todate);SqlDataAdapter sda = new SqlDataAdapter(cmd);{DataTable dt = new DataTable();sda.Fill(dt);return dt;}}} }asp.net<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
1. Single Line Comment The single line comment is specified using the symbol //Eg:// this is a AbundantCode comment Popular Code Guidelines or Standard Documents for .NET Developers2. Multi Line Comment The Multiline comment can be specified using the symbol /* */Eg:/* This is a test3. XML Comment This is a special kind of comment which is generally used for API documentation. The symbol /// is used to specify the XML comment in C#
c# contain 3 types of comments 1. Single line // 2. multiple line /* */ 3. XML comment /// it use for documentation
there are two types of comments in c#.. Single line i.e // comment single line and multiple lines i.e /* here multiple lines */
http://www.c-sharpcorner.com/uploadfile/puranindia/comments-in-C-Sharp/