0% found this document useful (0 votes)
33 views31 pages

Presentation C#

This is a presentation on C# where you can get introduced to C# programming languages and its basics
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views31 pages

Presentation C#

This is a presentation on C# where you can get introduced to C# programming languages and its basics
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 31

A MINI PROJECT

REPORT ON
"C#
PROGRAMMING"
• BY HARSH PAL SURYAVANSHI
• BTECH CSE A
• ROLL NUMBER – 2101200100062

SUBMITTED TO
SAURABH TIWARI
TABLE OF CONTENT :-
HISTORY OF C#
WHAT IS C# ? WHERE DO WE USE IT?
FEATURES OF C#
OBJECT ORIENTED PROGRAMMING
COLLECTIONS IN C#
ERROR HANDELING IN C#
INHERITANCE
INTERFACES AND POLYMORPHISM
STRUCTS IN C#
EVENTS AND DELEGATES
REGULAR EXPRESSION
WINDOWS PRESENTATION FOUNDATION
USING DATABASE WITH C#
LINQ
C# GENERICS
THREADS IN C#
UNIT TESTING – TEST DRIVEN DEVELOPMENT(TDD)
History Of C# :-

• C
• C++
• Developed by Anders Hejlsberg
• Origins and Early Development (1999–2000)
• Official Release (2000–2002)
• C# 2.0 (2005), C# 3.0 (2007), C# 4.0 (2010), C# 5.0 (2012), C# 6.0 (2015), C# 7.0 (2017), C# 8.0 (2019), C#
9.0 (2020), C# 10.0 (2021), C# 11.0 (2022) ,upcoming C# 12.0.

• Inspiration: C# was heavily influenced by languages like C++, Java, and Delphi. The goal was to create a
language that was simple, safe, and scalable, while being as powerful as C++ but easier to use.
• Design Goals: C# was designed to support modern software development practices, including strong
typing, garbage collection, object-oriented programming, and type safety.
What is C# ?

• C# (pronounced "C-sharp") is a modern, object-oriented programming language


developed by Microsoft. It was introduced in 2000 as part of the .NET framework.
• C# is designed to be simple, powerful, and versatile, making it suitable for a wide range of
programming tasks.
• It combines the power and flexibility of C++ with the ease of use and productivity of
Visual Basic.
Key Features of C#:

Object-Oriented: C# is built around the Type-Safe: C# enforces strong type


concept of objects and classes, which checking, which helps prevent errors
makes it easier to create modular, and enhances the reliability of the
reusable, and maintainable code. code.

Automatic Memory Management: C#


Interoperability: C# is designed to includes garbage collection, which
work seamlessly with other languages automatically handles memory
and technologies, particularly those in allocation and deallocation, reducing
the .NET ecosystem. the likelihood of memory leaks and
other related issues.
Where is C# Used?

Windows Applications: C# is widely


Web Applications: Using ASP.NET, a Game Development: C# is one of the
used to develop desktop applications
framework built on top of the .NET primary languages used in game
for the Windows operating system
platform, C# is commonly used to development, particularly with the
using frameworks like Windows
create dynamic and scalable web Unity game engine, which is popular
Presentation Foundation (WPF) and
applications. for creating 2D and 3D games.
Windows Forms.

Enterprise Applications: Many large


Mobile Applications: With Xamarin, a organizations use C# to build
Cloud Services: C# is used to develop
cross-platform mobile application enterprise-level applications due to
cloud-based applications and
development framework, developers its robust framework support,
services, especially on Microsoft
can use C# to create apps for scalability, and integration
Azure, a cloud computing platform.
Android, iOS, and Windows devices. capabilities with various Microsoft
products.

Automation and Tools Development:


C# is also used for scripting,
automation tasks, and creating tools,
particularly in environments where
Microsoft technologies are prevalent.
Features of C#:-

Object Oriented Programming

Enumerators

Operator Overloading

Windows API Invocation

Structured Error Handeling


Object Oriented Programming:-

•C# is object oriented. Every class is a subclass of an object. Everything is an object, yes
even primitives. This makes generic programming easier.

• Example:
• int n = 3;
• string s = n.ToString();
Enumerators:-

•Enumerators are a borrowed idea from C/C++. This is a data type consisting of a set of of
named integers.
•Example:
•enum Weekday {Mon, Tues, Wed, Thu, Fri, Sat, Sun};
Operator Overloading:-

•Operator Overloading is yet another idea borrowed from c++. This makes polymorphism
easier with custom data types.
•Example:
•Currency a, b, c;
•c = a + b;
Windows API Invocation:-

•C# was built with Windows in mind. It was created to allow programmers to create
Windows application easily through a wraparound API. Some other technologies supported
are COM, COM+.
Structured Error Handling:-

1 2 3
C# introduces new Try-catch blocks are To throw an object,
error handling used but with more it has to be a
techniques. functionality. subclass of
System.Exception.
Try-Catch:-

•C# was built with Windows in mind. It was created to allow programmers to create
Windows application easily through a wraparound API. Some other technologies supported
are COM, COM+.
Delegates:-

•Delegates provide a template for a single method.


•Example:
•public delegate int ArithOp(int a, int b);
•…
•public int DoOp(ArithOp ar)
•{ return ar(a, b); }
Namespace:-

•Namespace is a method of organizing similar files together. This is similar in some way to
the java package idea. Every program is either explicitly within a namespace or in by
default.
•Example:
•namespace Project{ public class P1{} }
•public class P2{}
Collections in C#

• • Types of collections:
• - List<T>
• - Dictionary<TKey, TValue>
• - Queue and Stack
• • Provides dynamic memory handling.
• • Example:
• List<int> numbers = new List<int> { 1, 2, 3 };
Error Handling in C#

• • Uses try, catch, finally for exception handling.


• • Supports custom exceptions by inheriting from Exception class.
• • Example:
• try { /* code */ } catch (Exception ex) { Console.WriteLine(ex.Message); }
Inheritance

• • Inheritance allows a class to inherit members from a base class.


• • Use the : symbol to denote inheritance.
• • Example:
• class BaseClass { public void Show() { Console.WriteLine("Base"); } }
• class DerivedClass : BaseClass { /* additional members */ }
Interfaces and Polymorphism

• • Interfaces define a contract that classes must adhere to.


• • C# supports multiple interface implementation.
• • Polymorphism allows methods to have different behaviors.
• • Example:
• interface IShape { void Draw(); }
• class Circle : IShape { public void Draw() { Console.WriteLine("Circle"); } }
Structs in C#

• • Structs are value types and can be used for lightweight objects.
• • Defined using the struct keyword.
• • Example:
• struct Point { public int X; public int Y; }
Events and Delegates

• • Delegates are type-safe function pointers.


• • Events use delegates to notify subscribers.
• • Example:
• delegate void Notify();
• event Notify OnNotify;
• OnNotify += () => Console.WriteLine("Event triggered");
Regular Expressions

• • Regular expressions are patterns used for matching strings.


• • The Regex class in C# provides powerful pattern-matching capabilities.
• • Example:
• Regex regex = new Regex(@"\d+");
• Match match = regex.Match("123abc");
Windows Presentation Foundation

• • WPF is a UI framework for building rich desktop applications.


• • Uses XAML (Extensible Application Markup Language) for UI design.
• • Example of XAML:
• <Button Content="Click Me" Width="100" Height="50" />
Using Database with C#

• • C# connects to databases using ADO.NET or Entity Framework.


• • Supports CRUD operations with SQL Server and other databases.
• • Example:
• using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); }
LINQ

• • Language Integrated Query (LINQ) is used for querying collections and databases.
• • Syntax:
• var result = from num in numbers where num > 5 select num;
• • Offers method-based syntax with functions like Select, Where, and GroupBy.
C# Generics

• • Generics allow type-safe data structures.


• • Examples include List<T>, Dictionary<TKey, TValue>.
• • Example of a custom generic class:
• class Box<T> { public T Value; }
Threads in C#

• • C# supports multithreading with the Thread class and Task Parallel Library (TPL).
• • Use async/await for asynchronous programming.
• • Example:
• Task.Run(() => Console.WriteLine("Running in a separate thread"));
Unit Testing – Test Driven Development
(TDD)

• • Unit testing ensures code correctness.


• • Use frameworks like NUnit or MSTest.
• • TDD involves writing tests before code.
• • Example:
• [Test]
• public void TestMethod() { Assert.AreEqual(2, 1 + 1); }
Future of C#:-

•With C#’s flexibility and support for many languages through the .NET architecture it will
definitely become a widely used language in all aspects of programming.
Course
Certificat
e:-
Thank You

You might also like