Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
SIRYKT
Sharing Knowledge is Learning
C# Tutorial
Introduction to C Sharp
• C# developed by Microsoft and comes after C, C++,
Java. It inherits the properties of C, C++, Java, VB.
• We can say C# is smart and intelligent sister of Java
because it do work smartly in compression to Java.
• The basic concept of C# language are same as C, C++ to
whom you have learnt in C, C++ tutorials.
• Launched in visual studio 2008
• Create a console with visual c# language
• It generates empty program class with main() method
• File extension in c#
• Project file extension: “.csproj” (Means c sharp project)
• Sample application development in C#
• Create a new “console application ” with “visual C#”
language
• It generates an empty “program” class with “main()”
method
• To run an application simply press f5 key on the
keyboard. Then the application will be executed and
output will be displayed
• Importing section:
• This section contain importing statements that are used to
import (including or link) the .NET framework class library
FCL.
• This is most similar to the include statement in c language
• Syntax: using namespace
• Note: if requires namespace is a member of another name
space. We have specify the parent and child namespaces
separate with “.” (dot).
• Ex: using system;
• Using system.io;
• Using system.data;
• Namespace declaration:
• here a user define namespace is to be declared
• Rule : In .NET applications, all the classes
related to the project should be declared in
one namespace.
• Syntax: namespace namespacename{}
• Generally, the namespace name will be same as
“project ” name.
• Class declaration:
• This is to declare the startup class of the
project.
• In every .NET application like console and
windows application. There should be a startup
class name should be “program” you cant
change it
• A startup class is nothing a class, which contain
main() method.
• Syntax: class classname{}
• Class
• Class is a data structure that contains data members
(constants files, events), member function methods,
properties, constructor, destructor, indexers and nested type.
Basically :
• It is a user defined data type.
• It is a reference type.
• In fact class is a tag or template for object.
• Drawback of Class
• Class does not allocate memory to its data members &
member function itself. Basically memory is allocated through
object of a class. Class can’t explore itself means it can not
access its members itself, to access members of a class we use
object of that class.
• Main() method:
• As you know already in c/c++ languages. The
main() method is the starting execution point
of the application
• When the application is executed the main
method will be executed first
• This method contains the main logic of the
application
• Class program
• {
• static void
• Main(string[] args)
• {
• Console.writeline (“hello world!”);
• Console.readline();
• }
• }
• Compiling and running application:
• Compile: click on “build” menu – “build solution”.(or) press ctrl +
shift + B
• Run:
• Click on “debug” menu – “start debugging” . (Or) press f5.
Object:
• Object is representative of the class and is responsible for
memory allocation of its data members and member
functions. An object is a real world entity having attributes
(data type) and behaviors (functions).
• Platform Support
• I've put this last only because it doesn't appear to differentiate
these languages as much as you might think. All these languages
can run on multiple OSes and machine architectures. C is the
most widely-supported, then C++, and finally C# (although C# can
be used on most major platforms thanks to an open source
implementation called Mono).
• My experience of porting C++ programs between Windows and
various Unix flavors was unpleasant. I've never tried porting
anything very complex in C# to Mono, so I can't comment on
that.
Leave feedback & questions in the comments
Hit on like button below
For more visit website www.sirykt.blogspot.com

More Related Content

Csharp introduction

  • 3. • C# developed by Microsoft and comes after C, C++, Java. It inherits the properties of C, C++, Java, VB. • We can say C# is smart and intelligent sister of Java because it do work smartly in compression to Java. • The basic concept of C# language are same as C, C++ to whom you have learnt in C, C++ tutorials. • Launched in visual studio 2008 • Create a console with visual c# language • It generates empty program class with main() method
  • 4. • File extension in c# • Project file extension: “.csproj” (Means c sharp project) • Sample application development in C# • Create a new “console application ” with “visual C#” language • It generates an empty “program” class with “main()” method • To run an application simply press f5 key on the keyboard. Then the application will be executed and output will be displayed
  • 5. • Importing section: • This section contain importing statements that are used to import (including or link) the .NET framework class library FCL. • This is most similar to the include statement in c language • Syntax: using namespace • Note: if requires namespace is a member of another name space. We have specify the parent and child namespaces separate with “.” (dot). • Ex: using system; • Using system.io; • Using system.data;
  • 6. • Namespace declaration: • here a user define namespace is to be declared • Rule : In .NET applications, all the classes related to the project should be declared in one namespace. • Syntax: namespace namespacename{} • Generally, the namespace name will be same as “project ” name.
  • 7. • Class declaration: • This is to declare the startup class of the project. • In every .NET application like console and windows application. There should be a startup class name should be “program” you cant change it • A startup class is nothing a class, which contain main() method. • Syntax: class classname{}
  • 8. • Class • Class is a data structure that contains data members (constants files, events), member function methods, properties, constructor, destructor, indexers and nested type. Basically : • It is a user defined data type. • It is a reference type. • In fact class is a tag or template for object. • Drawback of Class • Class does not allocate memory to its data members & member function itself. Basically memory is allocated through object of a class. Class can’t explore itself means it can not access its members itself, to access members of a class we use object of that class.
  • 9. • Main() method: • As you know already in c/c++ languages. The main() method is the starting execution point of the application • When the application is executed the main method will be executed first • This method contains the main logic of the application
  • 10. • Class program • { • static void • Main(string[] args) • { • Console.writeline (“hello world!”); • Console.readline(); • } • } • Compiling and running application: • Compile: click on “build” menu – “build solution”.(or) press ctrl + shift + B • Run: • Click on “debug” menu – “start debugging” . (Or) press f5.
  • 11. Object: • Object is representative of the class and is responsible for memory allocation of its data members and member functions. An object is a real world entity having attributes (data type) and behaviors (functions).
  • 12. • Platform Support • I've put this last only because it doesn't appear to differentiate these languages as much as you might think. All these languages can run on multiple OSes and machine architectures. C is the most widely-supported, then C++, and finally C# (although C# can be used on most major platforms thanks to an open source implementation called Mono). • My experience of porting C++ programs between Windows and various Unix flavors was unpleasant. I've never tried porting anything very complex in C# to Mono, so I can't comment on that.
  • 13. Leave feedback & questions in the comments Hit on like button below For more visit website www.sirykt.blogspot.com