0% found this document useful (0 votes)
5 views4 pages

C# Basics: Syntax, Data Types, and Examples

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views4 pages

C# Basics: Syntax, Data Types, and Examples

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

C#

======

IDE = Visual Studio - 2022


Framework

Project(Namespace) - Myproject

Collection of classes

Location - save the path

Solution -
collection of projects

Class
collection of methods and members

C#
====

. every statement end with semicolon;


. it is a case sensitive language
. do not use reserved keywords

output statements
=======================
[Link]()
[Link]()

input statements
==========================
[Link]()
[Link]()

hold the output screen until press any key


=====================

[Link]()

DataTypes

int a=10;
a -> integer variable
10 -> integer value

Value Type
int,float,decimal....etc

value types always contain range and specific memory


Reference Type
class,string,object,....etc
Operators
======================

Arithmetic operators - + - / % *
Assignment operators - = ?=
Comparison operators - > < >= <=
Equality operators - = ==
Boolean logical operators - true / false
Betwise and shift operators - && ||
Member access operators
Type-cast operators
Pointer related operators

Conditional statements
=======================

if
if else
else if
nested if

switch

condition for true or false statements

syntax
==========

if(condition) - true
{

}
else
{

Debug
===========

F9 - break point
F11 - step into
F10 - step out

using System;

namespace MyfirstConsole
{
internal class Program
{
static void Main()
{

byte age = 0;
[Link]("please enter your age");

age = [Link]([Link]());

if (age > 18)


{
[Link]("You r eligible for vote");
}

[Link]();

}
}

=================

using System;

namespace MyfirstConsole
{
internal class Program
{
static void Main()
{

byte age = 0;

[Link]("please enter your age");

age = [Link]([Link]());

if (age > 18)


{
[Link]("You r eligible for vote");
}
else
{
[Link]("You r not eligible for vote");
}

[Link]();

}
}

=============================

using System;

namespace MyfirstConsole
{
internal class Program
{
static void Main()
{

int atm = 0;

[Link]("please enter your atm pin");

atm = [Link]([Link]());

if (atm == 5674)
{
[Link]("Welcome to Axis Bank");
}
else
{
[Link]("Please enter correct pin!");
}

[Link]();

}
}

==============================

You might also like