-
Key Features and
Create a new project in Visual Studio 2022 - Naming Standards & Comments
- Data Types
- Variables and Constant Variable
- Conditional Statement
- Switch Conditional Statement
- Arithmetic, Comparison, Assignment and Logical Operators
- For, While and Do While Loops
- Importance of Break and Continue Keywords
- Strings and Important String Methods
- Single Dimensional Array
- Multi Dimensional Array
- Methods and Method Overloading
- Math Class and Functions
- Casting and Type Conversions
- Class and Objects
- Constructor, Parameter less and Parameterized Constructor
- Single, Multi level and Hierarchical Inheritance
- Compile Time Polymorphism, Method and Operator Overloading
- Run-time Polymorphism and Importance of base keyword
- Abstract Class and Method
- Interface and Multiple Inheritance through Interfaces
Agenda
- Difference between WriteLine and Write method in C#?
- C# Naming Standards
- C# Comments
- git rebase rewrites commit history but doesn’t create extra commit for merging
- C# Tutorial – Session 1
- C# Tutorial – Session 2 – Naming Standards
and Comments - C# Tutorial – Session 3
- C# Tutorial – Session 4 – Variables and
Constant in C - C# Tutorial – Session 5 – C# Conditional Statement
- C# Tutorial – Session 6 – C# Switch
Conditional Statement - C# Tutorial – Session 7 – C# Operators
Difference between WriteLine and Write method in C#?
- To print the data on the console output screen Console.Write() and Console.WriteLine() method can be used in C#. Console is a predefined class of System namespace. While Write() and WriteLine() both are the Console Class methods.
- The WriteLine method prints one or more object in a single line with a new line character inserted at the end. This means any subsequent output will be printed in a new line.
- The Write method is used to print one or more objects in a single line without inserting a new line character at the end.
- In the Write method, the cursor remains at the same line, while in WriteLine it moves to the next.
C# Naming Standards
There are following three terminologies being used to declare C# and .NET naming standards:
- Camel Case (camelCase): In this standard, the first letter of the word always in small letter and after that each word starts with a capital letter.
- Pascal Case (PascalCase and also called UpperCamelCase): In this the first letter of every word is in capital letter.
- Underscore Prefix (_underScore): For underscore ( _ ), the word after _ use camelCase terminology.
- Use PascalCase for class names. Try to use noun or noun phrase for class name. Do not give prefixes. Do not use underscores.
- Use PascalCase for method names. Use maximum 7 parameters in a method.
- Use camelCase with method arguments and local variables.
- Use letter "I" as prefix with name of interface. After letter I, use PascalCase.
- Always try to use camelCase terminology prefix with underscore ( _ ) for Private Member Variable.
- Use PascalCase for public member variable.
- Use PascalCase for namespace.
- Use PascalCasing in field names. Do not use a prefix and underscores for field names.
C# Comments
- Comments can be used to explain C# code, and to make it more readable.
- Comments are English words used for Code documentation.
- C# supports Single line comment and multiple lines comment.
- Comments in C# make the code Readable. It also make the code disable from execution
- Single-line comments start with two forward slashes ( // ). Any text between // and the end of the line is ignored by C# (will not be executed). Multi-line comments start with /* and ends with */.
Comments Syntax in C#:
Use // for Single line comments
Use /* ……
………..
…………..
*/ for Multiple lines comments
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
internal class Program
{
static void Main()
{
/*Console.Write("First C# Program - Line 1");
Console.Write(" First C# Program - Line 2");
Console.Write(" First C# Program - Line 3"); */
Console.WriteLine("First C# Program - Line 4");
Console.WriteLine(" First C# Program - Line 5"); //C# sinle line Comments
//Console.WriteLine(" First C# Program - Line 6");
Console.ReadKey();
}}