SlideShare a Scribd company logo
LEARN C#


Its very happy to introduced ourself. Our
Institution Adroit Infogen Pvt. Ltd. Corporation is
the industry leader in reliability consulting and
training services
 Has been founded in 2007 by Mr.R.Praneeth
Reddy .
It is to inform that we have been chosen as one
of the outsourcing agencies to start IT related
ESDP's [Entrepreneurship & Skill Development
Programs] by NI-MSME. In this connection we
wish to inform that we are conducting free
training programs for the students which
provided the certification in different programs
by NI-MSME, Ministry of MSME, Govt of India)
// Specify namespaces we use classes from here
using System;
using System.Threading; // Specify more specific namespaces
namespace AppNamespace
{
// Comments that start with /// used for
// creating online documentation, like javadoc
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
// .. Code for class goes here
}
}
class Class1
{
static void Main(string[] args)
{
// Your code would go here, e.g.
Console.WriteLine("hi");
}
/* We can define other methods and vars for the class */
// Constructor
Class1()
{
// Code
}
// Some method, use public, private, protected
// Use static as well just like Java
public void foo()
{
// Code
}
// Instance, Static Variables
private int m_number;
public static double m_stuff;
}




C# code normally uses the file extension of “.cs”.
Note similarities to Java


A few annoying differences, e.g. “Main” instead of “main”.

If a namespace is left out, your code is placed into
the default, global, namespace.
 The “using” directive tells C# what methods you
would like to use from that namespace.




If we left out the “using System” statement, then we would
have had to write “System.Console.WriteLine” instead of just
“Console.WriteLine”.

It is normal for each class to be defined in a separate
file, but you could put all the classes in one file if you
wish.


Using Visual Studio .NET’s “P)roject, Add C)lass” menu option
will create separate files for your classes by default.


If MSDN is installed







If MSDN is not installed, you can go online to access the
references. It is accessible from:





Online help resource built into Visual Studio .NET.
Help Menu, look up C# programming language reference
Dynamic Help

http://msdn.microsoft.com/library/default.asp
You will have to drill down to VS.NET, Documentation, VB and C#,
and then to the C# reference.

Both include numerous tutorials, or search on keywords


System.Console.WriteLine() will output a string to the
console. You can use this just like Java’s
System.out.println():
System.Console.WriteLine(“hello world “ + 10/2);

will output:
hello world 5
 We can also use {0}, {1}, {2}, … etc. to indicate
arguments in the WriteLine statement to print. For
example:
Console.WriteLine(“hi {0} you are {0} and your age is {1}”,
“Kenrick”, 23);

will output:
hi Kenrick you are Kenrick and your age is 23


There are also options to control things such as
the number of columns to use for each variable,
the number of decimals places to print, etc. For
example, we could use :C to specify the value
should be displayed as currency:
Console.WriteLine(“you have {0:C} dollars.”, 1.3);

outputs as:
you have $1.30 dollars.


See the online help or the text for more
formatting options.
 C#

supports value
types and reference
types.




Value types are
essentially the
primitive types found
in most languages,
and are stored
directly on the stack.
Reference types are
objects and are
created on the heap. Ref
type

Built-In Types
C# Type
bool
byte
sbyte
char
decimal
double
float
int
uint
long
ulong
object
short
ushort
string

.NET Framework type
System.Boolean
System.Byte
System.SByte
System.Char
System.Decimal
System.Double
System.Single
System.Int32
System.UInt32
System.Int64
System.UInt64
System.Object
System.Int16
System.UInt16
System.String


Automatic boxing and unboxing allows value types
can be treated like objects.
 For example, the following public methods are
defined for Object:
Equals
GetHashCode

GetType
ToString

We can then write code such as:
int i;
Console.WriteLine(i.ToString());
int hash = i.GetHashCode();
This is equivalent to performing:
z = new Object(i);
Console.WriteLine(z.ToString());

Overloaded. Determines whether two
Object instances are equal.
Serves as a hash function for a particular
type, suitable for use in hashing algorithms
and data structures like a hash table.
Gets the Type of the current instance.
Returns a String that represents the current
Object.

First version more efficient
due to automatic
boxing at VM level
 struct



is another value type

A struct can contain constructors, constants, fields,
methods, properties, indexers, operators, and nested
types.
Declaration of a struct looks just like a declaration of a
class, except we use the keyword struct instead of class.
For example:
public struct Point {
public int x, y;
public Point(int p1, int p2)
}

{

x = p1;

y = p2;

}

 So

what is the difference between a class and
struct? Unlike classes, structs can be created on
the stack without using the keyword new, e.g.:
Point p1, p2;
p1.x = 3; p1.y = 5;

 We

also cannot use inheritance with structs.
 Example:
// Enum goes outside in the class definition
enum Days {Sat, Sun, Mon, Tue, Wed, Thu, Fri};
// Inside some method
Days day1, day2;
int day3;
day1 = Days.Sat;
day2 = Days.Tue;
day3 = (int) Days.Fri;
Console.WriteLine(day1);
Console.WriteLine(day2);
Console.WriteLine(day3);

Output:

Sat
Tue
6

Enumeration really
maps to Int as the
underlying data type
 The

built-in string type is much like Java’s
string type.




Note lowercase string, not String
Concatenate using the + operator
Just like Java, there are a variety of methods
available to:






find the index Of matching strings or characters
generate substrings
compare for equality (if we use == on strings we are
comparing if the references are equal, just like Java)
generate clones, trim, etc.

 See

the reference for more details.
 Basic

class definition already covered
 To specify inheritance use a colon after the
class name and then the base class.




To invoke the constructor for the base class in a
derived class, we must use the keyword “base”
after the constructor in the derived class.
We must also be explicit with virtual methods,
methods are not virtual by default as with Java
public class BankAccount
{
public double m_amount;
BankAccount(double d) {
m_amount = d;
}
public virtual string GetInfo() {
return “Basic Account”;
}
}
public class SavingsAccount : BankAccount
{
// Savings Account derived from Bank Account
// usual inheritance of methods, variables
public double m_interest_rate;
SavingsAccount(double d) : base(100) {
m_interest_rate = 0.025;
}
public override string GetInfo() {
string s = base.GetInfo();
return s + “ and Savings Account”;
}
}

// $100 bonus for signup
SavingsAccount a = new
SavingsAccount(0.05);
Console.WriteLine(a.m_amount);
Console.WriteLine(a.m_interest_rate);
Console.WriteLine(a.GetInfo());

Then the output is:
100
0.05
Basic Account and Savings Account
 We

must explicitly state that a method is
virtual if we want to override it


By default, non-virtual methods cannot be
overridden

 We

also have to explicitly state that we
are overriding a method with the override
keyword
 To invoke a base method, use
base.methodName().
 An

interface in C# is much like an interface
in Java
 An interface states what an object can do,
but not how it is done.


It looks like a class definition but we cannot
implement any methods in the interface nor
include any variables.

 Here

is a sample interface:
public interface IDrivable {
void Start();
void Stop();
void Turn();
}

public class SportsCar : IDriveable {
void Start() {
// Code here to implement start
}
void Stop() {
// Code here to implement stop
}
void Turn() {
// Code here to implement turn
}
}

Method that uses the
Interface:
void
GoForward(IDrivable d)
{
d.Start();
// wait
d.Stop();
}
 To

input data, we must read it as a string and then
convert it to the desired type.


Console.ReadLine() will return a line of input text as a
string.

 We

can then use type.Parse(string) to convert the
string to the desired type. For example:
string s;
int i;
s = Console.ReadLine();
i = int.Parse(s);

 we

can also use double.Parse(s);
float.Parse(s);
etc.
 There is also a useful Convert class, with methods
such as Convert.ToDouble(val);
Convert.ToBoolean(val); Convert.ToDateTime(val);
etc.


We also have our familiar procedural constructs:









Arithmetic, relational, Boolean operators: all the same
as Java/C++
For, While, Do, If : all the same as Java/C++
Switch statements: Like Java, except forces a break
after a case. Code is not allowed to “fall through” to
the next case, but several case labels may mark the
same location.
Math class: Math.Sin(), Math.Cos(), etc.

Random class:
Random r = new Random();
r.NextDouble();
// Returns random double
between 0-1
r.Next(10,20);
// Random int, 10  int < 20
 Passing

a value variable by default refers to the
Pass by Value behavior as in Java
public static void foo(int a)
{
a=1;
}
static void Main(string[] args)
{
int x=3;
foo(x);
Console.WriteLine(x);
}

This outputs the value of 3 because x is passed by value to
method foo, which gets a copy of x’s value under the variable
name of a.
 C#

allows a ref keyword to pass value types by
reference:
public static void foo(int ref a)
{
a=1;
}
static void Main(string[] args)
{
int x=3;
foo(ref x);
Console.WriteLine(x);
}

The ref keyword must be used in both the parameter declaration
of the method and also when invoked, so it is clear what
parameters are passed by reference and may be changed.
Outputs the value of 1 since variable a in foo is really a reference
to where x is stored in Main.
 If

we pass a reference variable (Objects,
strings, etc. ) to a method, we get the same
behavior as in Java.
 Changes to the contents of the object are
reflected in the caller, since there is only one
copy of the actual object in memory and
merely multiple references to that object.
 Consider

the following:

public static void foo(string s)
{
s = "cow";
}
static void Main(string[] args)
{
string str = "moo";
foo(str);
Console.WriteLine(str);
}

 Output

is “moo” since inside method foo, the
local reference parameter s is set to a new
object in memory with the value “cow”. The
original reference in str remains untouched.
 The

following will change the string in the caller
public static void foo(string ref s)
{
s = "cow";
}
static void Main(string[] args)
{
string str = "moo";
foo(ref str);
Console.WriteLine(str);
}

 Output

str

= “cow” since foo is passed a reference to
 Arrays

in C# are quite similar to Java
arrays. Arrays are always created off the
heap and we have a reference to the
array data. The format is just like Java:
Type arrayname = new Type[size];

 For

example:

int arr = new int[100];

 This

allocates a chunk of data off the
heap large enough to store the array, and
arr references this chunk of data.






The Length property tells us the size of an array
dynamically
Console.WriteLine(arr.Length);
// Outputs 100 for above declaration

If we want to declare a method parameter to be of type
array we would use:
public void foo(int[] data)

To return an array we can use:
public int[] foo()

Just like in Java, if we have two array variables and want
to copy one to the other we can’t do it with just an
assignment.


This would assign the reference, not make a copy of the array.
 To copy the array we must copy each element one at a time,
or use the Clone() method to make a copy of the data and set
a new reference to it (and garbage collect the old array
values).




Two ways to declare multidimensional arrays.
The following defines a 30 x 3 array:
int[,] arr = new int[30][3];

Here we put a comma inside the [] to indicate two
dimensions.





This allocates a single chunk of memory of size 30*3*sizeof(int) and
creates a reference to it. We use the formulas for row major order
to access each element of the array.

The following defines a 30 x 3 array using an array of
arrays:
int[][] arr = new int[30][3];

To an end user this looks much like the previous
declaration, but it creates an array of 30 elements,
where each element is an array of 3 elements.




This gives us the possibility of creating ragged arrays but is slower
to access since we must dereference each array index.
Just like Java arrays


Check out the ArrayList class defined in
System.Collections.




Lastly, C# provides a new loop method, called
foreach




ArrayList is a class that behaves like a Java vector in
that it allows dynamic allocation of elements that can be
accessed like an array or also by name using a key.

Foreach will loop through each element in an array or
collection. For example:
string[] arr = {"hello", "world", "foo", "abracadabra"};
foreach (string x in arr) Console.WriteLine(x);

Will output each string in the array.
 C#

uses delegates where languages such as
C++ use function pointers.
 A delegate defines a class that describes one
or more methods.



Another method can use this definition,
regardless of the actual code that implements it.
C# uses this technique to pass the EventHandlers
to the system, where the event may be handled
in different ways.
Compare1 uses alphabetic comparison, Compare2 uses length
// Two different methods for comparison
public static int compare1(string s1, string s2)
{
return (s1.CompareTo(s2));
}
public static int compare2(string s1, string s2)
{
if (s1.Length <= s2.Length) return -1;
else return 1;
}
public delegate int CompareDelegate(string s1, string s2);
// A method that uses the delegate to find the minimum
public static string FindMin(string[] arr, CompareDelegate compare)
{
int i, minIndex=0;
for (i=1; i<arr.Length; i++)
{
if (compare(arr[minIndex],arr[i])>0) minIndex=i;
}
return arr[minIndex];
}

static void Main(string[] args)
{
string[] arr = {"hello", "world", "foo", "abracadabra"};
string s;
Console.WriteLine(FindMin(arr, new CompareDelegate(compare1)));
Console.WriteLine(FindMin(arr, new CompareDelegate(compare2)));
}

The output of this code is:
abracadabra
foo

(using compare1, alphabetic compare)
(using compare2, length of string compare)
 Here

we have covered all of the basic
constructs that exist in the C# language
under the Common Language Runtime!

 Next

we will see how to use various
Windows.Forms features to create Windows
applications with graphical interfaces.
 www.adroitinfogen.in


ADDRESS:
 11-1-192,GANDHI
ROAD,TIRUPATI.
 CONTACT:08776669994



ADDRESS:
100B,PRAKASHAM
ROAD,TIRUPATI.
CONTACT:7799151599

www.adroitinfogen.in
LEARN C LANGUAGE IN 21 DAYS
CREATED BY ADROIT INFOGEN PVT LTD


Its very happy to introduced ourself. Our
Institution Adroit Infogen Pvt. Ltd. Corporation
is the industry leader in reliability consulting
and training services
 Has been founded in 2007 by Mr.R.Praneeth
Reddy .
It is to inform that we have been chosen as one of
the outsourcing agencies to start IT related
ESDP's [Entrepreneurship & Skill Development
Programs] by NI-MSME. In this connection we
wish to inform that we are conducting free
training programs for the students which
provided the certification in different programs
by NI-MSME, Ministry of MSME, Govt of India)
WEEK 1:OVERVIEW:


An Introduction To Computer.



Computer hardware



Computer software



Algorithms



Flowcharts



Pseudocodes
INTRODUCTION TO C


Overview Of C.



Basic Structure Of C Programs.



Executing a C Programs.



Data Types.



Decleration Of Variables.



Operators And Expressions.
ARRAYS


Introduction



One Dimension Arrays.



Two Dimension Arrays.



Multi Dimension Arrays.



Dynamic Arrays.



Math Functions.
USER-DEFINED FUNCTIONS


Introduction



Definition Of Function



Function Declaration



Category of Functions



Recursion



Preprocessor Commands
POINTERS:


Introduction About Pointers



Declaring Pointer Variables.



Pointer Expression.



Pointer & Arrays.



Pointers to Functions.



Pointers to Structures.
STRINGS


Introduction To Strings.



Declaring & Initializing String Variables.



Arithmetic Operators on Characters



String handling Functions.



String/Data Conversion.
STRUCTURES & UNIONS


Defining a Structures.



Structure Initialization.



Arrays of Structures.



Structures & Functions.



Unions
FILE MANAGEMENT IN C


Introduction.



Types of Files.



Defining And Opening A File,Closing File.



Input /Output operations On Files.



Error Handling During I/O Operations.



Random Access to Files.



Command line arguments
DATA STRUCTURES


Abstract Data Types.



Linear List.



Stacks.



Stack Implementation.



Applications Of Stacks.



Queues



Queues implementation
SEARCHING & SORTING TECHNIQUES



Introduction.



Sorting.



Searching.
THANK YOU

www.adroitinfogen.in
ADROIT INFOGEN PVT LTD
 Address

:
11-1-192, Near
KrishnaPuram Tana,
Gandhi Road,
Tirupati.
 Cont: 0877 6669994

 Address

:
100B, Opp TTD
Complex,
Prakasham Road,
Tirupati.
Cont: +91 7799151599

www.adroitinfogen.in
LEARN JAVA IN
21 DAYS
(3 WEEKS)
INNOVATES

RELATIONS
GENERATED BY ADROIT INFOGEN PVT LTD


Its very happy to introduced ourself. Our Institution
Adroit Infogen Pvt. Ltd. Corporation is the industry
leader in reliability consulting and training services
 Has been founded in 2007 by Mr.R.Praneeth Reddy .
It is to inform that we have been chosen as one of the
outsourcing agencies to start IT related
ESDP's [Entrepreneurship & Skill Development
Programs] by NI-MSME. In this connection we wish
to inform that we are conducting free training
programs for the students which provided the
certification in different programs by NI-MSME,
Ministry of MSME, Govt of India)
OVERVIEW


WEEK-1

An Introduction To Java


What Is Java?
 Why Learn Java?
 Getting Started With Programming In Java
 Creating Java Application And Applet


Object Oriented Programming And Java





Thinking In Objects
Objects and Classes
Behavior and Attributes
Inheritance , Interface and Packages


Java Basics









Statements and Expressions
Variables and Datatypes
Literals
Expressions and Operators
String Arithmetic

Working With Objects


Creating New Objects
 Accessing and Setting Class and Instance Variable
 Calling Methods
 Casting and Converting Objects
 Odds and Ends


Arrays, Conditionals and Loops


Arrays
 Block Statements
 IFC Conditions
 Switch Conditionals
 While and do Loops
 Breaking Out The Loops


Creating Class and Applications In Java


Defining Class
 Creating Instance and Class Variables
 Creating Methods
 Creating Java Applications
 Java Applications and Command-Line Arguments
WEEK-2




Java Applet Basics


How Applets and Applications are Different
 Creating Applets
 Including An Applet On a Web Page
 Passing Parameters To Applets

Graphics, Fonts and Color





The Graphics Class
Drawing and Filling
Text and Fonts
Color


Simple Animations and Threads







Creating Animation In Java
Threads What They Are?
Reducing Animations Flicker

Managing Simple Events and Interactivity





Mouse Clicks
Mouse Movements
Keyboard Events
AWT Event Handler




The Java Abstract Windowing ToolKit


An AWT Overview
 The Basic User Interface Components
 Panels and Layout
 Handling UI Actions and Events
 Nesting Panels and Components

Windows Networking and Other Tidbits



Windows Menus and Dialogue boxes
Networking In Java
WEEK-3




Modifiers


Method and Variable Access Control
 Class Variables and Methods
 The Final Modifier
 Abstract Classes and Methods

Packages and Interfaces
 Exceptions



Programming In the Large
Programming In the Small




Multithreading


The Problem With Parallelism
 Thinking Multithreaded
 Creating and Using Threads
 Thread Scheduling

Streams




Input Streams
Output Streams
Related Classes


Native Methods and Libraries







The Illusion Of Required Efficiency
Writing Native Methods
A Native Library

Under the Hood


The Big Picture
 The Java Virtual Machine
 Byte codes in More Detail
 Method Signatures
 The Garbage Collector
 The Security Story
THANKING YOU

www.adroitinfogen.in
ADROIT INFOGEN PRIVATE LIMITED
BRIGING SUCCESS TO YOU …..

Address 1 :
11 – 1- 192, Near Krishna
Puram tana,Gandhi Road
Tirupati
Cont : 0877 - 6669994

Address 2:
100 B, Prakasam Road
Tirupati

Cont: +91 7799151599

www.adroitinfogen.in

More Related Content

What's hot (20)

PDF
C# Summer course - Lecture 3
mohamedsamyali
 
PPTX
Structure & Union in C++
Davinder Kaur
 
PPSX
Support for Object-Oriented Programming (OOP) in C++
Ameen Sha'arawi
 
PDF
Java ppt Gandhi Ravi ([email protected])
Gandhi Ravi
 
PDF
201005 accelerometer and core Location
Javier Gonzalez-Sanchez
 
PPTX
Objective c slide I
Diksha Bhargava
 
PDF
Op ps
Shehzad Rizwan
 
PDF
C# Summer course - Lecture 4
mohamedsamyali
 
PDF
Introduction to objective c
Sunny Shaikh
 
PPTX
Learn Concept of Class and Object in C# Part 3
C# Learning Classes
 
PDF
Overview Of Msil
Ganesh Samarthyam
 
PPTX
Java Programming For Android
TechiNerd
 
PPTX
OOP C++
Ahmed Farag
 
PPSX
DIWE - Working with MySQL Databases
Rasan Samarasinghe
 
PPTX
Object oriented programming with python
Arslan Arshad
 
PDF
Java Persistence API
Ilio Catallo
 
PDF
1204csharp
g_hemanth17
 
PPT
Structure and union
Samsil Arefin
 
PDF
Inheritance
Prof. Dr. K. Adisesha
 
C# Summer course - Lecture 3
mohamedsamyali
 
Structure & Union in C++
Davinder Kaur
 
Support for Object-Oriented Programming (OOP) in C++
Ameen Sha'arawi
 
Java ppt Gandhi Ravi ([email protected])
Gandhi Ravi
 
201005 accelerometer and core Location
Javier Gonzalez-Sanchez
 
Objective c slide I
Diksha Bhargava
 
C# Summer course - Lecture 4
mohamedsamyali
 
Introduction to objective c
Sunny Shaikh
 
Learn Concept of Class and Object in C# Part 3
C# Learning Classes
 
Overview Of Msil
Ganesh Samarthyam
 
Java Programming For Android
TechiNerd
 
OOP C++
Ahmed Farag
 
DIWE - Working with MySQL Databases
Rasan Samarasinghe
 
Object oriented programming with python
Arslan Arshad
 
Java Persistence API
Ilio Catallo
 
1204csharp
g_hemanth17
 
Structure and union
Samsil Arefin
 

Similar to LEARN C# (20)

PPT
Synapseindia dot net development
Synapseindiappsdevelopment
 
PPT
Learn C# at ASIT
ASIT
 
PPTX
Java Basics 1.pptx
TouseeqHaider11
 
PPTX
CSharp Presentation
Vishwa Mohan
 
PPTX
OOC MODULE1.pptx
1HK19CS090MOHAMMEDSA
 
PPTX
Notes(1).pptx
InfinityWorld3
 
PDF
C Sharp: Basic to Intermediate Part 01
Zafor Iqbal
 
PPT
Csharp4 basics
Abed Bukhari
 
PPT
iOS Application Development
Compare Infobase Limited
 
PPTX
Cordovilla
brianmae002
 
PPTX
unit 1 (1).pptx
PriyadarshiniS28
 
PPTX
Object Oriented Programming using c++.pptx
olisahchristopher
 
ODP
Ppt of c++ vs c#
shubhra chauhan
 
PPTX
Advanced programming topics asma
AbdullahJana
 
PPTX
Learning space presentation1 learn Java script
engmk83
 
PPTX
CSharp presentation and software developement
frwebhelp
 
PPTX
Clean Code
Nascenia IT
 
PDF
Object-oriented programming (OOP) with Complete understanding modules
Durgesh Singh
 
PDF
Big Brother helps you
PVS-Studio
 
Synapseindia dot net development
Synapseindiappsdevelopment
 
Learn C# at ASIT
ASIT
 
Java Basics 1.pptx
TouseeqHaider11
 
CSharp Presentation
Vishwa Mohan
 
OOC MODULE1.pptx
1HK19CS090MOHAMMEDSA
 
Notes(1).pptx
InfinityWorld3
 
C Sharp: Basic to Intermediate Part 01
Zafor Iqbal
 
Csharp4 basics
Abed Bukhari
 
iOS Application Development
Compare Infobase Limited
 
Cordovilla
brianmae002
 
unit 1 (1).pptx
PriyadarshiniS28
 
Object Oriented Programming using c++.pptx
olisahchristopher
 
Ppt of c++ vs c#
shubhra chauhan
 
Advanced programming topics asma
AbdullahJana
 
Learning space presentation1 learn Java script
engmk83
 
CSharp presentation and software developement
frwebhelp
 
Clean Code
Nascenia IT
 
Object-oriented programming (OOP) with Complete understanding modules
Durgesh Singh
 
Big Brother helps you
PVS-Studio
 
Ad

Recently uploaded (20)

PDF
Lesson 1 - Nature of Inquiry and Research.pdf
marvinnbustamante1
 
PDF
Our Guide to the July 2025 USPS® Rate Change
Postal Advocate Inc.
 
PDF
IMPORTANT GUIDELINES FOR M.Sc.ZOOLOGY DISSERTATION
raviralanaresh2
 
DOCX
Lesson 1 - Nature and Inquiry of Research
marvinnbustamante1
 
PDF
Lesson 1 : Science and the Art of Geography Ecosystem
marvinnbustamante1
 
PPTX
How to Configure Taxes in Company Currency in Odoo 18 Accounting
Celine George
 
PPTX
Aerobic and Anaerobic respiration and CPR.pptx
Olivier Rochester
 
PDF
Lean IP - Lecture by Dr Oliver Baldus at the MIPLM 2025
MIPLM
 
PDF
WATERSHED MANAGEMENT CASE STUDIES - ULUGURU MOUNTAINS AND ARVARI RIVERpdf
Ar.Asna
 
PPTX
Exploring Linear and Angular Quantities and Ergonomic Design.pptx
AngeliqueTolentinoDe
 
PPTX
MATH 8 QUARTER 1 WEEK 1 LESSON 2 PRESENTATION
JohnGuillerNestalBah1
 
PPTX
Building Powerful Agentic AI with Google ADK, MCP, RAG, and Ollama.pptx
Tamanna36
 
PPTX
PLANNING A HOSPITAL AND NURSING UNIT.pptx
PRADEEP ABOTHU
 
PDF
Supply Chain Security A Comprehensive Approach 1st Edition Arthur G. Arway
rxgnika452
 
PPTX
Ward Management: Patient Care, Personnel, Equipment, and Environment.pptx
PRADEEP ABOTHU
 
PPTX
How to Configure Refusal of Applicants in Odoo 18 Recruitment
Celine George
 
PPTX
Natural Language processing using nltk.pptx
Ramakrishna Reddy Bijjam
 
PDF
Free eBook ~100 Common English Proverbs (ebook) pdf.pdf
OH TEIK BIN
 
PPTX
The Gift of the Magi by O Henry-A Story of True Love, Sacrifice, and Selfless...
Beena E S
 
PDF
Quiz Night Live May 2025 - Intra Pragya Online General Quiz
Pragya - UEM Kolkata Quiz Club
 
Lesson 1 - Nature of Inquiry and Research.pdf
marvinnbustamante1
 
Our Guide to the July 2025 USPS® Rate Change
Postal Advocate Inc.
 
IMPORTANT GUIDELINES FOR M.Sc.ZOOLOGY DISSERTATION
raviralanaresh2
 
Lesson 1 - Nature and Inquiry of Research
marvinnbustamante1
 
Lesson 1 : Science and the Art of Geography Ecosystem
marvinnbustamante1
 
How to Configure Taxes in Company Currency in Odoo 18 Accounting
Celine George
 
Aerobic and Anaerobic respiration and CPR.pptx
Olivier Rochester
 
Lean IP - Lecture by Dr Oliver Baldus at the MIPLM 2025
MIPLM
 
WATERSHED MANAGEMENT CASE STUDIES - ULUGURU MOUNTAINS AND ARVARI RIVERpdf
Ar.Asna
 
Exploring Linear and Angular Quantities and Ergonomic Design.pptx
AngeliqueTolentinoDe
 
MATH 8 QUARTER 1 WEEK 1 LESSON 2 PRESENTATION
JohnGuillerNestalBah1
 
Building Powerful Agentic AI with Google ADK, MCP, RAG, and Ollama.pptx
Tamanna36
 
PLANNING A HOSPITAL AND NURSING UNIT.pptx
PRADEEP ABOTHU
 
Supply Chain Security A Comprehensive Approach 1st Edition Arthur G. Arway
rxgnika452
 
Ward Management: Patient Care, Personnel, Equipment, and Environment.pptx
PRADEEP ABOTHU
 
How to Configure Refusal of Applicants in Odoo 18 Recruitment
Celine George
 
Natural Language processing using nltk.pptx
Ramakrishna Reddy Bijjam
 
Free eBook ~100 Common English Proverbs (ebook) pdf.pdf
OH TEIK BIN
 
The Gift of the Magi by O Henry-A Story of True Love, Sacrifice, and Selfless...
Beena E S
 
Quiz Night Live May 2025 - Intra Pragya Online General Quiz
Pragya - UEM Kolkata Quiz Club
 
Ad

LEARN C#

  • 2.  Its very happy to introduced ourself. Our Institution Adroit Infogen Pvt. Ltd. Corporation is the industry leader in reliability consulting and training services  Has been founded in 2007 by Mr.R.Praneeth Reddy . It is to inform that we have been chosen as one of the outsourcing agencies to start IT related ESDP's [Entrepreneurship & Skill Development Programs] by NI-MSME. In this connection we wish to inform that we are conducting free training programs for the students which provided the certification in different programs by NI-MSME, Ministry of MSME, Govt of India)
  • 3. // Specify namespaces we use classes from here using System; using System.Threading; // Specify more specific namespaces namespace AppNamespace { // Comments that start with /// used for // creating online documentation, like javadoc /// <summary> /// Summary description for Class1. /// </summary> class Class1 { // .. Code for class goes here } }
  • 4. class Class1 { static void Main(string[] args) { // Your code would go here, e.g. Console.WriteLine("hi"); } /* We can define other methods and vars for the class */ // Constructor Class1() { // Code } // Some method, use public, private, protected // Use static as well just like Java public void foo() { // Code } // Instance, Static Variables private int m_number; public static double m_stuff; }
  • 5.    C# code normally uses the file extension of “.cs”. Note similarities to Java  A few annoying differences, e.g. “Main” instead of “main”. If a namespace is left out, your code is placed into the default, global, namespace.  The “using” directive tells C# what methods you would like to use from that namespace.   If we left out the “using System” statement, then we would have had to write “System.Console.WriteLine” instead of just “Console.WriteLine”. It is normal for each class to be defined in a separate file, but you could put all the classes in one file if you wish.  Using Visual Studio .NET’s “P)roject, Add C)lass” menu option will create separate files for your classes by default.
  • 6.  If MSDN is installed     If MSDN is not installed, you can go online to access the references. It is accessible from:    Online help resource built into Visual Studio .NET. Help Menu, look up C# programming language reference Dynamic Help http://msdn.microsoft.com/library/default.asp You will have to drill down to VS.NET, Documentation, VB and C#, and then to the C# reference. Both include numerous tutorials, or search on keywords
  • 7.  System.Console.WriteLine() will output a string to the console. You can use this just like Java’s System.out.println(): System.Console.WriteLine(“hello world “ + 10/2); will output: hello world 5  We can also use {0}, {1}, {2}, … etc. to indicate arguments in the WriteLine statement to print. For example: Console.WriteLine(“hi {0} you are {0} and your age is {1}”, “Kenrick”, 23); will output: hi Kenrick you are Kenrick and your age is 23
  • 8.  There are also options to control things such as the number of columns to use for each variable, the number of decimals places to print, etc. For example, we could use :C to specify the value should be displayed as currency: Console.WriteLine(“you have {0:C} dollars.”, 1.3); outputs as: you have $1.30 dollars.  See the online help or the text for more formatting options.
  • 9.  C# supports value types and reference types.   Value types are essentially the primitive types found in most languages, and are stored directly on the stack. Reference types are objects and are created on the heap. Ref type Built-In Types C# Type bool byte sbyte char decimal double float int uint long ulong object short ushort string .NET Framework type System.Boolean System.Byte System.SByte System.Char System.Decimal System.Double System.Single System.Int32 System.UInt32 System.Int64 System.UInt64 System.Object System.Int16 System.UInt16 System.String
  • 10.  Automatic boxing and unboxing allows value types can be treated like objects.  For example, the following public methods are defined for Object: Equals GetHashCode GetType ToString We can then write code such as: int i; Console.WriteLine(i.ToString()); int hash = i.GetHashCode(); This is equivalent to performing: z = new Object(i); Console.WriteLine(z.ToString()); Overloaded. Determines whether two Object instances are equal. Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table. Gets the Type of the current instance. Returns a String that represents the current Object. First version more efficient due to automatic boxing at VM level
  • 11.  struct   is another value type A struct can contain constructors, constants, fields, methods, properties, indexers, operators, and nested types. Declaration of a struct looks just like a declaration of a class, except we use the keyword struct instead of class. For example: public struct Point { public int x, y; public Point(int p1, int p2) } { x = p1; y = p2; }  So what is the difference between a class and struct? Unlike classes, structs can be created on the stack without using the keyword new, e.g.: Point p1, p2; p1.x = 3; p1.y = 5;  We also cannot use inheritance with structs.
  • 12.  Example: // Enum goes outside in the class definition enum Days {Sat, Sun, Mon, Tue, Wed, Thu, Fri}; // Inside some method Days day1, day2; int day3; day1 = Days.Sat; day2 = Days.Tue; day3 = (int) Days.Fri; Console.WriteLine(day1); Console.WriteLine(day2); Console.WriteLine(day3); Output: Sat Tue 6 Enumeration really maps to Int as the underlying data type
  • 13.  The built-in string type is much like Java’s string type.    Note lowercase string, not String Concatenate using the + operator Just like Java, there are a variety of methods available to:     find the index Of matching strings or characters generate substrings compare for equality (if we use == on strings we are comparing if the references are equal, just like Java) generate clones, trim, etc.  See the reference for more details.
  • 14.  Basic class definition already covered  To specify inheritance use a colon after the class name and then the base class.   To invoke the constructor for the base class in a derived class, we must use the keyword “base” after the constructor in the derived class. We must also be explicit with virtual methods, methods are not virtual by default as with Java
  • 15. public class BankAccount { public double m_amount; BankAccount(double d) { m_amount = d; } public virtual string GetInfo() { return “Basic Account”; } } public class SavingsAccount : BankAccount { // Savings Account derived from Bank Account // usual inheritance of methods, variables public double m_interest_rate; SavingsAccount(double d) : base(100) { m_interest_rate = 0.025; } public override string GetInfo() { string s = base.GetInfo(); return s + “ and Savings Account”; } } // $100 bonus for signup
  • 16. SavingsAccount a = new SavingsAccount(0.05); Console.WriteLine(a.m_amount); Console.WriteLine(a.m_interest_rate); Console.WriteLine(a.GetInfo()); Then the output is: 100 0.05 Basic Account and Savings Account
  • 17.  We must explicitly state that a method is virtual if we want to override it  By default, non-virtual methods cannot be overridden  We also have to explicitly state that we are overriding a method with the override keyword  To invoke a base method, use base.methodName().
  • 18.  An interface in C# is much like an interface in Java  An interface states what an object can do, but not how it is done.  It looks like a class definition but we cannot implement any methods in the interface nor include any variables.  Here is a sample interface:
  • 19. public interface IDrivable { void Start(); void Stop(); void Turn(); } public class SportsCar : IDriveable { void Start() { // Code here to implement start } void Stop() { // Code here to implement stop } void Turn() { // Code here to implement turn } } Method that uses the Interface: void GoForward(IDrivable d) { d.Start(); // wait d.Stop(); }
  • 20.  To input data, we must read it as a string and then convert it to the desired type.  Console.ReadLine() will return a line of input text as a string.  We can then use type.Parse(string) to convert the string to the desired type. For example: string s; int i; s = Console.ReadLine(); i = int.Parse(s);  we can also use double.Parse(s); float.Parse(s); etc.  There is also a useful Convert class, with methods such as Convert.ToDouble(val); Convert.ToBoolean(val); Convert.ToDateTime(val); etc.
  • 21.  We also have our familiar procedural constructs:      Arithmetic, relational, Boolean operators: all the same as Java/C++ For, While, Do, If : all the same as Java/C++ Switch statements: Like Java, except forces a break after a case. Code is not allowed to “fall through” to the next case, but several case labels may mark the same location. Math class: Math.Sin(), Math.Cos(), etc. Random class: Random r = new Random(); r.NextDouble(); // Returns random double between 0-1 r.Next(10,20); // Random int, 10  int < 20
  • 22.  Passing a value variable by default refers to the Pass by Value behavior as in Java public static void foo(int a) { a=1; } static void Main(string[] args) { int x=3; foo(x); Console.WriteLine(x); } This outputs the value of 3 because x is passed by value to method foo, which gets a copy of x’s value under the variable name of a.
  • 23.  C# allows a ref keyword to pass value types by reference: public static void foo(int ref a) { a=1; } static void Main(string[] args) { int x=3; foo(ref x); Console.WriteLine(x); } The ref keyword must be used in both the parameter declaration of the method and also when invoked, so it is clear what parameters are passed by reference and may be changed. Outputs the value of 1 since variable a in foo is really a reference to where x is stored in Main.
  • 24.  If we pass a reference variable (Objects, strings, etc. ) to a method, we get the same behavior as in Java.  Changes to the contents of the object are reflected in the caller, since there is only one copy of the actual object in memory and merely multiple references to that object.
  • 25.  Consider the following: public static void foo(string s) { s = "cow"; } static void Main(string[] args) { string str = "moo"; foo(str); Console.WriteLine(str); }  Output is “moo” since inside method foo, the local reference parameter s is set to a new object in memory with the value “cow”. The original reference in str remains untouched.
  • 26.  The following will change the string in the caller public static void foo(string ref s) { s = "cow"; } static void Main(string[] args) { string str = "moo"; foo(ref str); Console.WriteLine(str); }  Output str = “cow” since foo is passed a reference to
  • 27.  Arrays in C# are quite similar to Java arrays. Arrays are always created off the heap and we have a reference to the array data. The format is just like Java: Type arrayname = new Type[size];  For example: int arr = new int[100];  This allocates a chunk of data off the heap large enough to store the array, and arr references this chunk of data.
  • 28.     The Length property tells us the size of an array dynamically Console.WriteLine(arr.Length); // Outputs 100 for above declaration If we want to declare a method parameter to be of type array we would use: public void foo(int[] data) To return an array we can use: public int[] foo() Just like in Java, if we have two array variables and want to copy one to the other we can’t do it with just an assignment.  This would assign the reference, not make a copy of the array.  To copy the array we must copy each element one at a time, or use the Clone() method to make a copy of the data and set a new reference to it (and garbage collect the old array values).
  • 29.    Two ways to declare multidimensional arrays. The following defines a 30 x 3 array: int[,] arr = new int[30][3]; Here we put a comma inside the [] to indicate two dimensions.    This allocates a single chunk of memory of size 30*3*sizeof(int) and creates a reference to it. We use the formulas for row major order to access each element of the array. The following defines a 30 x 3 array using an array of arrays: int[][] arr = new int[30][3]; To an end user this looks much like the previous declaration, but it creates an array of 30 elements, where each element is an array of 3 elements.   This gives us the possibility of creating ragged arrays but is slower to access since we must dereference each array index. Just like Java arrays
  • 30.  Check out the ArrayList class defined in System.Collections.   Lastly, C# provides a new loop method, called foreach   ArrayList is a class that behaves like a Java vector in that it allows dynamic allocation of elements that can be accessed like an array or also by name using a key. Foreach will loop through each element in an array or collection. For example: string[] arr = {"hello", "world", "foo", "abracadabra"}; foreach (string x in arr) Console.WriteLine(x); Will output each string in the array.
  • 31.  C# uses delegates where languages such as C++ use function pointers.  A delegate defines a class that describes one or more methods.   Another method can use this definition, regardless of the actual code that implements it. C# uses this technique to pass the EventHandlers to the system, where the event may be handled in different ways.
  • 32. Compare1 uses alphabetic comparison, Compare2 uses length // Two different methods for comparison public static int compare1(string s1, string s2) { return (s1.CompareTo(s2)); } public static int compare2(string s1, string s2) { if (s1.Length <= s2.Length) return -1; else return 1; }
  • 33. public delegate int CompareDelegate(string s1, string s2); // A method that uses the delegate to find the minimum public static string FindMin(string[] arr, CompareDelegate compare) { int i, minIndex=0; for (i=1; i<arr.Length; i++) { if (compare(arr[minIndex],arr[i])>0) minIndex=i; } return arr[minIndex]; } static void Main(string[] args) { string[] arr = {"hello", "world", "foo", "abracadabra"}; string s; Console.WriteLine(FindMin(arr, new CompareDelegate(compare1))); Console.WriteLine(FindMin(arr, new CompareDelegate(compare2))); } The output of this code is: abracadabra foo (using compare1, alphabetic compare) (using compare2, length of string compare)
  • 34.  Here we have covered all of the basic constructs that exist in the C# language under the Common Language Runtime!  Next we will see how to use various Windows.Forms features to create Windows applications with graphical interfaces.
  • 37. LEARN C LANGUAGE IN 21 DAYS
  • 38. CREATED BY ADROIT INFOGEN PVT LTD  Its very happy to introduced ourself. Our Institution Adroit Infogen Pvt. Ltd. Corporation is the industry leader in reliability consulting and training services  Has been founded in 2007 by Mr.R.Praneeth Reddy . It is to inform that we have been chosen as one of the outsourcing agencies to start IT related ESDP's [Entrepreneurship & Skill Development Programs] by NI-MSME. In this connection we wish to inform that we are conducting free training programs for the students which provided the certification in different programs by NI-MSME, Ministry of MSME, Govt of India)
  • 39. WEEK 1:OVERVIEW:  An Introduction To Computer.  Computer hardware  Computer software  Algorithms  Flowcharts  Pseudocodes
  • 40. INTRODUCTION TO C  Overview Of C.  Basic Structure Of C Programs.  Executing a C Programs.  Data Types.  Decleration Of Variables.  Operators And Expressions.
  • 41. ARRAYS  Introduction  One Dimension Arrays.  Two Dimension Arrays.  Multi Dimension Arrays.  Dynamic Arrays.  Math Functions.
  • 42. USER-DEFINED FUNCTIONS  Introduction  Definition Of Function  Function Declaration  Category of Functions  Recursion  Preprocessor Commands
  • 43. POINTERS:  Introduction About Pointers  Declaring Pointer Variables.  Pointer Expression.  Pointer & Arrays.  Pointers to Functions.  Pointers to Structures.
  • 44. STRINGS  Introduction To Strings.  Declaring & Initializing String Variables.  Arithmetic Operators on Characters  String handling Functions.  String/Data Conversion.
  • 45. STRUCTURES & UNIONS  Defining a Structures.  Structure Initialization.  Arrays of Structures.  Structures & Functions.  Unions
  • 46. FILE MANAGEMENT IN C  Introduction.  Types of Files.  Defining And Opening A File,Closing File.  Input /Output operations On Files.  Error Handling During I/O Operations.  Random Access to Files.  Command line arguments
  • 47. DATA STRUCTURES  Abstract Data Types.  Linear List.  Stacks.  Stack Implementation.  Applications Of Stacks.  Queues  Queues implementation
  • 48. SEARCHING & SORTING TECHNIQUES  Introduction.  Sorting.  Searching.
  • 50. ADROIT INFOGEN PVT LTD  Address : 11-1-192, Near KrishnaPuram Tana, Gandhi Road, Tirupati.  Cont: 0877 6669994  Address : 100B, Opp TTD Complex, Prakasham Road, Tirupati. Cont: +91 7799151599 www.adroitinfogen.in
  • 51. LEARN JAVA IN 21 DAYS (3 WEEKS)
  • 53. GENERATED BY ADROIT INFOGEN PVT LTD  Its very happy to introduced ourself. Our Institution Adroit Infogen Pvt. Ltd. Corporation is the industry leader in reliability consulting and training services  Has been founded in 2007 by Mr.R.Praneeth Reddy . It is to inform that we have been chosen as one of the outsourcing agencies to start IT related ESDP's [Entrepreneurship & Skill Development Programs] by NI-MSME. In this connection we wish to inform that we are conducting free training programs for the students which provided the certification in different programs by NI-MSME, Ministry of MSME, Govt of India)
  • 54. OVERVIEW  WEEK-1 An Introduction To Java  What Is Java?  Why Learn Java?  Getting Started With Programming In Java  Creating Java Application And Applet  Object Oriented Programming And Java     Thinking In Objects Objects and Classes Behavior and Attributes Inheritance , Interface and Packages
  • 55.  Java Basics       Statements and Expressions Variables and Datatypes Literals Expressions and Operators String Arithmetic Working With Objects  Creating New Objects  Accessing and Setting Class and Instance Variable  Calling Methods  Casting and Converting Objects  Odds and Ends
  • 56.  Arrays, Conditionals and Loops  Arrays  Block Statements  IFC Conditions  Switch Conditionals  While and do Loops  Breaking Out The Loops
  • 57.  Creating Class and Applications In Java  Defining Class  Creating Instance and Class Variables  Creating Methods  Creating Java Applications  Java Applications and Command-Line Arguments
  • 58. WEEK-2   Java Applet Basics  How Applets and Applications are Different  Creating Applets  Including An Applet On a Web Page  Passing Parameters To Applets Graphics, Fonts and Color     The Graphics Class Drawing and Filling Text and Fonts Color
  • 59.  Simple Animations and Threads     Creating Animation In Java Threads What They Are? Reducing Animations Flicker Managing Simple Events and Interactivity     Mouse Clicks Mouse Movements Keyboard Events AWT Event Handler
  • 60.   The Java Abstract Windowing ToolKit  An AWT Overview  The Basic User Interface Components  Panels and Layout  Handling UI Actions and Events  Nesting Panels and Components Windows Networking and Other Tidbits   Windows Menus and Dialogue boxes Networking In Java
  • 61. WEEK-3   Modifiers  Method and Variable Access Control  Class Variables and Methods  The Final Modifier  Abstract Classes and Methods Packages and Interfaces  Exceptions   Programming In the Large Programming In the Small
  • 62.   Multithreading  The Problem With Parallelism  Thinking Multithreaded  Creating and Using Threads  Thread Scheduling Streams    Input Streams Output Streams Related Classes
  • 63.  Native Methods and Libraries     The Illusion Of Required Efficiency Writing Native Methods A Native Library Under the Hood  The Big Picture  The Java Virtual Machine  Byte codes in More Detail  Method Signatures  The Garbage Collector  The Security Story
  • 65. ADROIT INFOGEN PRIVATE LIMITED BRIGING SUCCESS TO YOU ….. Address 1 : 11 – 1- 192, Near Krishna Puram tana,Gandhi Road Tirupati Cont : 0877 - 6669994 Address 2: 100 B, Prakasam Road Tirupati Cont: +91 7799151599 www.adroitinfogen.in