SlideShare a Scribd company logo
Basic Introduction to C#
Why C# ?
• Builds on COM+ experience
• Native support for
    – Namespaces
    – Versioning
    – Attribute-driven development
•   Power of C with ease of Microsoft Visual Basic®
•   Minimal learning curve for everybody
•   Much cleaner than C++
•   More structured than Visual Basic
•   More powerful than Java
C# – The Big Ideas
            A component oriented language
• The first “component oriented” language in
     the C/C++ family
   – In OOP a component is: A reusable program that can be
     combined with other components in the same system to form
     an application.
   – Example: a single button in a graphical user interface, a small
     interest calculator
   – They can be deployed on different servers and communicate
     with each other

• Enables one-stop programming
          – No header files, IDL, etc.
          – Can be embedded in web pages
C# Overview
• Object oriented
• Everything belongs to a class
  – no global scope
• Complete C# program:
           using System;
           namespace ConsoleTest
           {
                   class Class1
                   {
                            static void Main(string[] args)
                            {
                            }
                   }
           }
C# Program Structure
•   Namespaces
    –   Contain types and other namespaces
•   Type declarations
    –   Classes, structs, interfaces, enums,
        and delegates
•   Members
    –   Constants, fields, methods, properties, events, operators,
        constructors, destructors
•   Organization
    –   No header files, code written “in-line”
    –   No declaration order dependence
Simple Types
• Integer Types
   – byte, sbyte (8bit), short, ushort (16bit)
   – int, uint (32bit), long, ulong (64bit)

• Floating Point Types
   – float (precision of 7 digits)
   – double (precision of 15–16 digits)

• Exact Numeric Type
   – decimal (28 significant digits)

• Character Types
   – char (single character)
   – string (rich functionality, by-reference type)

• Boolean Type
   – bool (distinct type, not interchangeable with int)
Arrays
• Zero based, type bound
• Built on .NET System.Array class
• Declared with type and shape, but no bounds
   – int [ ] SingleDim;
   – int [ , ] TwoDim;
   – int [ ][ ] Jagged;
• Created using new with bounds or initializers
   – SingleDim = new int[20];
   – TwoDim = new int[,]{{1,2,3},{4,5,6}};
   – Jagged = new int[1][ ];
     Jagged[0] = new int[ ]{1,2,3};
Statements and Comments

•   Case sensitive (myVar != MyVar)
•   Statement delimiter is semicolon        ;
•   Block delimiter is curly brackets       { }
•   Single line comment is                  //
•   Block comment is                        /* */
     – Save block comments for debugging!
Data
• All data types derived from
  System.Object
• Declarations:
    datatype varname;
    datatype varname = initvalue;
• C# does not automatically initialize local
  variables (but will warn you)!
Value Data Types
• Directly contain their data:
  –   int      (numbers)
  –   long     (really big numbers)
  –   bool     (true or false)
  –   char     (unicode characters)
  –   float    (7-digit floating point numbers)
  –   string   (multiple characters together)
Data Manipulation

=      assignment
+      addition
-      subtraction
*      multiplication
/      division
%      modulus
++ increment by one
--     decrement by one
strings
• Immutable sequence of Unicode characters
  (char)

• Creation:
  – string s = “Bob”;
  – string s = new String(“Bob”);

• Backslash is an escape:
  – Newline: “n”
  – Tab: “t”
string/int conversions
• string to numbers:
  – int i = int.Parse(“12345”);
  – float f = float.Parse(“123.45”);


• Numbers to strings:
  – string msg = “Your number is ” + 123;
  – string msg = “It costs ” +
                  string.Format(“{0:C}”, 1.23);
String Example
using System;
namespace ConsoleTest
{
       class Class1
       {
                 static void Main(string[ ] args)
                 {
                             int myInt;
                             string myStr = "2";
                             bool myCondition = true;

                            Console.WriteLine("Before: myStr = " + myStr);
                            myInt = int.Parse(myStr);
                            myInt++;
                            myStr = String.Format("{0}", myInt);
                            Console.WriteLine("After: myStr = " + myStr);

                            while(myCondition) ;
                 }
       }
}
Arrays
•   (page 21 of quickstart handout)
•   Derived from System.Array
•   Use square brackets          []
•   Zero-based
•   Static size
•   Initialization:
    – int [ ] nums;
    – int [ ] nums = new int[3]; // 3 items
    – int [ ] nums = new int[ ] {10, 20, 30};
Arrays Continued
• Use Length for # of items in array:
   – nums.Length
• Static Array methods:
   – Sort           System.Array.Sort(myArray);
   – Reverse System.Array.Reverse(myArray);
   – IndexOf
   – LastIndexOf
   Int myLength = myArray.Length;
   System.Array.IndexOf(myArray, “K”, 0, myLength)
Arrays Final
• Multidimensional

   // 3 rows, 2 columns
   int [ , ] myMultiIntArray = new int[3,2]

   for(int r=0; r<3; r++)
   {
         myMultiIntArray[r][0] = 0;
         myMultiIntArray[r][1] = 0;
   }
Conditional Operators

   == equals
   !=     not equals

   <      less than
   <= less than or equal
   >      greater than
   >= greater than or equal

   &&    and
   ||    or
If, Case Statements

if (expression)      switch (i) {
                        case 1:
   { statements; }
                             statements;
else if                      break;
                        case 2:
   { statements; }
                             statements;
else                         break;
                        default:
   { statements; }           statements;
                             break;
                     }
Loops

for (initialize-statement; condition; increment-statement);
{
   statements;
}


while (condition)
{
  statements;
}

      Note: can include break and continue statements
Classes, Members and Methods
  • Everything is encapsulated in a class
  • Can have:
     – member data
     – member methods

        Class clsName
        {
            modifier dataType varName;
            modifier returnType methodName (params)
            {
               statements;
               return returnVal;
            }
        }
Class Constructors
• Automatically called when an object is
  instantiated:

  public className(parameters)
  {
     statements;
  }
Hello World

namespace Sample
{
    using System;

    public class HelloWorld
                               Constructor
    {
        public HelloWorld()
        {
        }

          public static int Main(string[]
  args)
          {
              Console.WriteLine("Hello
  World!");
              return 0;
          }
    }
Another Example
using System;
namespace ConsoleTest
{
      public class Class1
      {
             public string FirstName = "Kay";
             public string LastName = "Connelly";

            public string GetWholeName()
            {
                        return FirstName + " " + LastName;
            }

            static void Main(string[] args)
            {
                  Class1 myClassInstance = new Class1();

                  Console.WriteLine("Name: " + myClassInstance.GetWholeName());

                  while(true) ;
            }
      }
}
Summary
• C# builds on the .NET Framework
  component model
• New language with familiar structure
  – Easy to adopt for developers of C, C++, Java,
    and Visual Basic applications
• Fully object oriented
• Optimized for the .NET Framework
ASP .Net and C#
• Easily combined and ready to be used in
  WebPages.
• Powerful
• Fast
• Most of the works are done without
  getting stuck in low level programming and
  driver fixing and …
An ASP.Net Simple Start
End of The C#

More Related Content

What's hot

Applets in java
Applets in javaApplets in java
Applets in java
Wani Zahoor
 
C# in depth
C# in depthC# in depth
C# in depth
Arnon Axelrod
 
CSharp Presentation
CSharp PresentationCSharp Presentation
CSharp Presentation
Vishwa Mohan
 
C# Basics
C# BasicsC# Basics
C# Basics
Sunil OS
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
arvind pandey
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#Doncho Minkov
 
C# programming language
C# programming languageC# programming language
C# programming language
swarnapatil
 
C# Exceptions Handling
C# Exceptions Handling C# Exceptions Handling
C# Exceptions Handling
sharqiyem
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
Andres Baravalle
 
Introduction to .net framework
Introduction to .net frameworkIntroduction to .net framework
Introduction to .net framework
Arun Prasad
 
Introduction To Dotnet
Introduction To DotnetIntroduction To Dotnet
Introduction To Dotnet
SAMIR BHOGAYTA
 
DOT Net overview
DOT Net overviewDOT Net overview
DOT Net overview
chandrasekhardesireddi
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
Michelle Anne Meralpis
 
9. Input Output in java
9. Input Output in java9. Input Output in java
9. Input Output in java
Nilesh Dalvi
 
Android Programming Basics
Android Programming BasicsAndroid Programming Basics
Android Programming Basics
Eueung Mulyana
 
Bootstrap
BootstrapBootstrap
Bootstrap
Jadson Santos
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
Rajkumarsoy
 
Basics of JAVA programming
Basics of JAVA programmingBasics of JAVA programming
Basics of JAVA programming
Elizabeth Thomas
 
Object-oriented concepts
Object-oriented conceptsObject-oriented concepts
Object-oriented concepts
BG Java EE Course
 

What's hot (20)

Applets in java
Applets in javaApplets in java
Applets in java
 
C# in depth
C# in depthC# in depth
C# in depth
 
CSharp Presentation
CSharp PresentationCSharp Presentation
CSharp Presentation
 
C# Basics
C# BasicsC# Basics
C# Basics
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#
 
C# programming language
C# programming languageC# programming language
C# programming language
 
C# Exceptions Handling
C# Exceptions Handling C# Exceptions Handling
C# Exceptions Handling
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
Introduction to .net framework
Introduction to .net frameworkIntroduction to .net framework
Introduction to .net framework
 
Introduction To Dotnet
Introduction To DotnetIntroduction To Dotnet
Introduction To Dotnet
 
DOT Net overview
DOT Net overviewDOT Net overview
DOT Net overview
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
 
9. Input Output in java
9. Input Output in java9. Input Output in java
9. Input Output in java
 
Introduction to .NET Framework
Introduction to .NET FrameworkIntroduction to .NET Framework
Introduction to .NET Framework
 
Android Programming Basics
Android Programming BasicsAndroid Programming Basics
Android Programming Basics
 
Bootstrap
BootstrapBootstrap
Bootstrap
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
 
Basics of JAVA programming
Basics of JAVA programmingBasics of JAVA programming
Basics of JAVA programming
 
Object-oriented concepts
Object-oriented conceptsObject-oriented concepts
Object-oriented concepts
 

Similar to Introduction to c#

Dr archana dhawan bajaj - csharp fundamentals slides
Dr archana dhawan bajaj - csharp fundamentals slidesDr archana dhawan bajaj - csharp fundamentals slides
Dr archana dhawan bajaj - csharp fundamentals slides
Dr-archana-dhawan-bajaj
 
4java Basic Syntax
4java Basic Syntax4java Basic Syntax
4java Basic SyntaxAdil Jafri
 
Java
Java Java
Java introduction
Java introductionJava introduction
Java introduction
Samsung Electronics Egypt
 
For Beginners - C#
For Beginners - C#For Beginners - C#
For Beginners - C#
Snehal Harawande
 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.ppt
ssuser0c24d5
 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.ppt
nilesh405711
 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.ppt
YashpalYadav46
 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.ppt
DevliNeeraj
 
UsingCPP_for_Artist.ppt
UsingCPP_for_Artist.pptUsingCPP_for_Artist.ppt
UsingCPP_for_Artist.ppt
vinu28455
 
Oop c++class(final).ppt
Oop c++class(final).pptOop c++class(final).ppt
Oop c++class(final).pptAlok Kumar
 
Data types and Operators
Data types and OperatorsData types and Operators
Data types and Operators
raksharao
 
Net framework
Net frameworkNet framework
Net framework
Abhishek Mukherjee
 
Dr archana dhawan bajaj - c# dot net
Dr archana dhawan bajaj - c# dot netDr archana dhawan bajaj - c# dot net
Dr archana dhawan bajaj - c# dot net
Dr-archana-dhawan-bajaj
 
C++ process new
C++ process newC++ process new
C++ process new
敬倫 林
 
c++ ppt.ppt
c++ ppt.pptc++ ppt.ppt
c++ ppt.ppt
FarazKhan89093
 
Introduction to C#
Introduction to C#Introduction to C#
Introduction to C#
ANURAG SINGH
 

Similar to Introduction to c# (20)

C# for beginners
C# for beginnersC# for beginners
C# for beginners
 
Dr archana dhawan bajaj - csharp fundamentals slides
Dr archana dhawan bajaj - csharp fundamentals slidesDr archana dhawan bajaj - csharp fundamentals slides
Dr archana dhawan bajaj - csharp fundamentals slides
 
4java Basic Syntax
4java Basic Syntax4java Basic Syntax
4java Basic Syntax
 
Java
Java Java
Java
 
Java introduction
Java introductionJava introduction
Java introduction
 
For Beginners - C#
For Beginners - C#For Beginners - C#
For Beginners - C#
 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.ppt
 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.ppt
 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.ppt
 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.ppt
 
UsingCPP_for_Artist.ppt
UsingCPP_for_Artist.pptUsingCPP_for_Artist.ppt
UsingCPP_for_Artist.ppt
 
Csharp_mahesh
Csharp_maheshCsharp_mahesh
Csharp_mahesh
 
Oop c++class(final).ppt
Oop c++class(final).pptOop c++class(final).ppt
Oop c++class(final).ppt
 
Data types and Operators
Data types and OperatorsData types and Operators
Data types and Operators
 
Net framework
Net frameworkNet framework
Net framework
 
Dr archana dhawan bajaj - c# dot net
Dr archana dhawan bajaj - c# dot netDr archana dhawan bajaj - c# dot net
Dr archana dhawan bajaj - c# dot net
 
C# for Java Developers
C# for Java DevelopersC# for Java Developers
C# for Java Developers
 
C++ process new
C++ process newC++ process new
C++ process new
 
c++ ppt.ppt
c++ ppt.pptc++ ppt.ppt
c++ ppt.ppt
 
Introduction to C#
Introduction to C#Introduction to C#
Introduction to C#
 

More from OpenSource Technologies Pvt. Ltd.

OpenSource Technologies Portfolio
OpenSource Technologies PortfolioOpenSource Technologies Portfolio
OpenSource Technologies Portfolio
OpenSource Technologies Pvt. Ltd.
 
Cloud Computing Amazon
Cloud Computing AmazonCloud Computing Amazon
Cloud Computing Amazon
OpenSource Technologies Pvt. Ltd.
 
Empower your business with joomla
Empower your business with joomlaEmpower your business with joomla
Empower your business with joomla
OpenSource Technologies Pvt. Ltd.
 
Responsive Web Design Fundamentals
Responsive Web Design FundamentalsResponsive Web Design Fundamentals
Responsive Web Design Fundamentals
OpenSource Technologies Pvt. Ltd.
 
MySQL Training
MySQL TrainingMySQL Training
PHP Shield - The PHP Encoder
PHP Shield - The PHP EncoderPHP Shield - The PHP Encoder
PHP Shield - The PHP Encoder
OpenSource Technologies Pvt. Ltd.
 
Zend Framework
Zend FrameworkZend Framework
Introduction to Ubantu
Introduction to UbantuIntroduction to Ubantu
Introduction to Ubantu
OpenSource Technologies Pvt. Ltd.
 
WordPress Plugins
WordPress PluginsWordPress Plugins
WordPress Complete Tutorial
WordPress Complete TutorialWordPress Complete Tutorial
WordPress Complete Tutorial
OpenSource Technologies Pvt. Ltd.
 
Intro dotnet
Intro dotnetIntro dotnet
OST Profile
OST ProfileOST Profile

More from OpenSource Technologies Pvt. Ltd. (13)

OpenSource Technologies Portfolio
OpenSource Technologies PortfolioOpenSource Technologies Portfolio
OpenSource Technologies Portfolio
 
Cloud Computing Amazon
Cloud Computing AmazonCloud Computing Amazon
Cloud Computing Amazon
 
Empower your business with joomla
Empower your business with joomlaEmpower your business with joomla
Empower your business with joomla
 
Responsive Web Design Fundamentals
Responsive Web Design FundamentalsResponsive Web Design Fundamentals
Responsive Web Design Fundamentals
 
MySQL Training
MySQL TrainingMySQL Training
MySQL Training
 
PHP Shield - The PHP Encoder
PHP Shield - The PHP EncoderPHP Shield - The PHP Encoder
PHP Shield - The PHP Encoder
 
Zend Framework
Zend FrameworkZend Framework
Zend Framework
 
Introduction to Ubantu
Introduction to UbantuIntroduction to Ubantu
Introduction to Ubantu
 
WordPress Plugins
WordPress PluginsWordPress Plugins
WordPress Plugins
 
WordPress Complete Tutorial
WordPress Complete TutorialWordPress Complete Tutorial
WordPress Complete Tutorial
 
Intro dotnet
Intro dotnetIntro dotnet
Intro dotnet
 
Asp.net
Asp.netAsp.net
Asp.net
 
OST Profile
OST ProfileOST Profile
OST Profile
 

Recently uploaded

DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
Alex Pruden
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 

Recently uploaded (20)

DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 

Introduction to c#

  • 2. Why C# ? • Builds on COM+ experience • Native support for – Namespaces – Versioning – Attribute-driven development • Power of C with ease of Microsoft Visual Basic® • Minimal learning curve for everybody • Much cleaner than C++ • More structured than Visual Basic • More powerful than Java
  • 3. C# – The Big Ideas A component oriented language • The first “component oriented” language in the C/C++ family – In OOP a component is: A reusable program that can be combined with other components in the same system to form an application. – Example: a single button in a graphical user interface, a small interest calculator – They can be deployed on different servers and communicate with each other • Enables one-stop programming – No header files, IDL, etc. – Can be embedded in web pages
  • 4. C# Overview • Object oriented • Everything belongs to a class – no global scope • Complete C# program: using System; namespace ConsoleTest { class Class1 { static void Main(string[] args) { } } }
  • 5. C# Program Structure • Namespaces – Contain types and other namespaces • Type declarations – Classes, structs, interfaces, enums, and delegates • Members – Constants, fields, methods, properties, events, operators, constructors, destructors • Organization – No header files, code written “in-line” – No declaration order dependence
  • 6. Simple Types • Integer Types – byte, sbyte (8bit), short, ushort (16bit) – int, uint (32bit), long, ulong (64bit) • Floating Point Types – float (precision of 7 digits) – double (precision of 15–16 digits) • Exact Numeric Type – decimal (28 significant digits) • Character Types – char (single character) – string (rich functionality, by-reference type) • Boolean Type – bool (distinct type, not interchangeable with int)
  • 7. Arrays • Zero based, type bound • Built on .NET System.Array class • Declared with type and shape, but no bounds – int [ ] SingleDim; – int [ , ] TwoDim; – int [ ][ ] Jagged; • Created using new with bounds or initializers – SingleDim = new int[20]; – TwoDim = new int[,]{{1,2,3},{4,5,6}}; – Jagged = new int[1][ ]; Jagged[0] = new int[ ]{1,2,3};
  • 8. Statements and Comments • Case sensitive (myVar != MyVar) • Statement delimiter is semicolon ; • Block delimiter is curly brackets { } • Single line comment is // • Block comment is /* */ – Save block comments for debugging!
  • 9. Data • All data types derived from System.Object • Declarations: datatype varname; datatype varname = initvalue; • C# does not automatically initialize local variables (but will warn you)!
  • 10. Value Data Types • Directly contain their data: – int (numbers) – long (really big numbers) – bool (true or false) – char (unicode characters) – float (7-digit floating point numbers) – string (multiple characters together)
  • 11. Data Manipulation = assignment + addition - subtraction * multiplication / division % modulus ++ increment by one -- decrement by one
  • 12. strings • Immutable sequence of Unicode characters (char) • Creation: – string s = “Bob”; – string s = new String(“Bob”); • Backslash is an escape: – Newline: “n” – Tab: “t”
  • 13. string/int conversions • string to numbers: – int i = int.Parse(“12345”); – float f = float.Parse(“123.45”); • Numbers to strings: – string msg = “Your number is ” + 123; – string msg = “It costs ” + string.Format(“{0:C}”, 1.23);
  • 14. String Example using System; namespace ConsoleTest { class Class1 { static void Main(string[ ] args) { int myInt; string myStr = "2"; bool myCondition = true; Console.WriteLine("Before: myStr = " + myStr); myInt = int.Parse(myStr); myInt++; myStr = String.Format("{0}", myInt); Console.WriteLine("After: myStr = " + myStr); while(myCondition) ; } } }
  • 15. Arrays • (page 21 of quickstart handout) • Derived from System.Array • Use square brackets [] • Zero-based • Static size • Initialization: – int [ ] nums; – int [ ] nums = new int[3]; // 3 items – int [ ] nums = new int[ ] {10, 20, 30};
  • 16. Arrays Continued • Use Length for # of items in array: – nums.Length • Static Array methods: – Sort System.Array.Sort(myArray); – Reverse System.Array.Reverse(myArray); – IndexOf – LastIndexOf Int myLength = myArray.Length; System.Array.IndexOf(myArray, “K”, 0, myLength)
  • 17. Arrays Final • Multidimensional // 3 rows, 2 columns int [ , ] myMultiIntArray = new int[3,2] for(int r=0; r<3; r++) { myMultiIntArray[r][0] = 0; myMultiIntArray[r][1] = 0; }
  • 18. Conditional Operators == equals != not equals < less than <= less than or equal > greater than >= greater than or equal && and || or
  • 19. If, Case Statements if (expression) switch (i) { case 1: { statements; } statements; else if break; case 2: { statements; } statements; else break; default: { statements; } statements; break; }
  • 20. Loops for (initialize-statement; condition; increment-statement); { statements; } while (condition) { statements; } Note: can include break and continue statements
  • 21. Classes, Members and Methods • Everything is encapsulated in a class • Can have: – member data – member methods Class clsName { modifier dataType varName; modifier returnType methodName (params) { statements; return returnVal; } }
  • 22. Class Constructors • Automatically called when an object is instantiated: public className(parameters) { statements; }
  • 23. Hello World namespace Sample { using System; public class HelloWorld Constructor { public HelloWorld() { } public static int Main(string[] args) { Console.WriteLine("Hello World!"); return 0; } }
  • 24. Another Example using System; namespace ConsoleTest { public class Class1 { public string FirstName = "Kay"; public string LastName = "Connelly"; public string GetWholeName() { return FirstName + " " + LastName; } static void Main(string[] args) { Class1 myClassInstance = new Class1(); Console.WriteLine("Name: " + myClassInstance.GetWholeName()); while(true) ; } } }
  • 25. Summary • C# builds on the .NET Framework component model • New language with familiar structure – Easy to adopt for developers of C, C++, Java, and Visual Basic applications • Fully object oriented • Optimized for the .NET Framework
  • 26. ASP .Net and C# • Easily combined and ready to be used in WebPages. • Powerful • Fast • Most of the works are done without getting stuck in low level programming and driver fixing and …