SlideShare una empresa de Scribd logo
1 de 19
Descargar para leer sin conexión
Стандартна
бібліотека класів c#
Зміст
1.    Що таке Generic? Extension methods.
2.    Math
3.    DateTime, TimeSpan
4.    Regex
5.    Колекції. System.Collections, System.Collections.Generic.
6.    Nullable<T>, “type?”
7.    Path
8.    DriveInfo
9.    Directory
10.   File
11.   Encodings
12.   Streams
13.   Serializationdeserializations
Generics
    • Generic methods:
       • FirstOrDefault<T>(T[] array)
       • FirstOrDefault<T>(T[] array, T defaultValue)

    • Type inference:
        • int first = FirstOrDefault(new[] {3, 2, 1});

    • default(T) expression

    • Type constraints:
        • Base type, class, struct, new()

    • Generic types:
       • Example: List<T>

http://msdn.microsoft.com/en-us/library/ms379564(v=vs.80).aspx
Extension methods

                               Simply static methods

                                  Used for convenience




http://msdn.microsoft.com/en-us/library/bb383977.aspx
Math

       • Math.Abs(number)
       • Math.Pow(number)
       • Math.Sin(angle)
       • Math.Cos(angle)
       • Math.Max(number1, number2)
       • Math.Min(number1, number2)
       • …




http://msdn.microsoft.com/en-us/library/system.math.aspx
DateTime
   • DateTime – представляє значення дати та часу.
       • DateTime.Add(timeSpan)
       • DateTime.AddDay(number)….
       • DateTime.ToString(format) (hh:mm:ss)
       • ToLocalTime()
       • ToUniversalTime()
       • DateTime.Now
       • DateTime.UtcNow
       • …
   • TimeSpan – представляє інтервали дати та часу.
       • TimeSpan.TotalMilliseconds
       • TimeSpan.Days
       • TimeSpan.TotalDays
       • …



http://msdn.microsoft.com/en-us/library/system.datetime.aspx - DateTime
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx - Custom DateTime Formats
Regex
   Email pattern: “b[A-Z0-9._%-]+@[A-Z0-9.-]+.[A-Z]{2,4}b”


   • Regex.IsMatch(pattern, string)
   • Regex.Replace(pattern, string, newValue)




http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.aspx
Collections
      Collections:
      • Hashtable
      • ArrayList
      • Queue
      • Stack

    Collections.Generic:
    • Dictionary<TKey, TValue>
    • List<T>
    • Queue<T>
    • Stack<T>
    • LinkedList<T>

http://msdn.microsoft.com/en-us/library/system.collections.aspx - Collections
http://msdn.microsoft.com/en-us/library/0sbxh9x2.aspx - Collections.Generic
Nullable<T>

       int? = Nullable<int>

       Useful properties:
       • HasValue
       • Value




http://msdn.microsoft.com/en-us/library/b3h38hb0.aspx
Path

      • Path.Combine(path1, path2)
      • Path.GetDirectoryName(path)
      • Path.GetFileName(path)
      • Path.GetExtension(path)
      • Path.GetFullPath(path)


      • Path.GetRandomFileName()
      • Path.GetTempFileName()
      • Path.GetTempPath()




http://msdn.microsoft.com/en-us/library/system.io.path_methods.aspx
DriveInfo

        • DriveInfo.GetDrives()




        • drive.DriveType {CDRom, Fixed, Unknown, Network, Removable ….}
        • drive.DriveFormat {NTFS, FAT32}
        • drive. AvailableFreeSpace




http://msdn.microsoft.com/en-us/library/system.io.driveinfo.aspx
Directory

     • Directory.Create(folderPath)
     • Directory.Move(folderPath, destinationPath)
     • Directory.Delete(folderPath) && Directory.Delete(folderPath, true/*recursive*/)
     • Directory.Exists(folderPath)


     • Directory.GetFiles(folderPath, [search pattern])




http://msdn.microsoft.com/en-us/library/system.io.directory.aspx
File
      • File.Create(filePath)
      • File.Move(filePath, filePathDestination)
      • File.Copy(filePath, filePathDestination)
      • File.Delete(filePath)
      • File.Exists(filePath)


      • File.WriteAllText(filePath, text)
      • File.WriteAllBytes(filePath, bytes)
      • File.AppendText(filePath, text)
      • File.ReadAllText(filePath)
      • File.ReadAllBytes(filePath)

http://msdn.microsoft.com/en-us/library/system.io.file.aspx
Encoding
        •   Encoding.Default
        •   Encoding.Unicode
        •   Encoding.ASCII
        •   Encoding.UTF32
        •   …
        •   Encoding.Convert(sourceEncoding, destinationEncoding, bytes)

        • encoding.GetBytes(string)
        • encoding.GetString(bytes)




http://msdn.microsoft.com/en-us/library/system.text.encoding.aspx
Streams
       •   stream.Read(data, offset, count)                                      Stream
       •   stream.Write(data, offset, count)
       •   stream.Length
                                                                                           CryptoStream
       •   stream.Seek(offset, SeekOrigin)
       •   stream.Close()                                  MemoryStream
                                                                                    FileStream

       • StreamWriter – easy way to write into text files.
       • StreamReader – easy way to read text from files.

       • FileStream – easy way to work with binary files.

       Create FileStream:
       • constructor (new FileStream(path, FileMode, FileAccess))
       • File.Create
       • File.Open
       • File.Write
http://msdn.microsoft.com/en-us/library/system.io.stream.aspx - Stream
http://msdn.microsoft.com/en-us/library/system.io.filestream.aspx - FileStream
Binary serialization
  [Serializable]
  public class MyObject
  {
          public int n1 = 0;
          public int n2 = 0;
          public String str = null;
  }

   Serizalization
   MyObject obj = new MyObject();
   obj.n1 = 1;
   obj.n2 = 24;
   obj.str = "Some String";
   IFormatter formatter = new BinaryFormatter();
   Stream stream = new FileStream("MyFile.bin", FileMode.Create, FileAccess.Write, FileShare.None);
   formatter.Serialize(stream, obj);
   stream.Close();

   Deserizalization
   IFormatter formatter = new BinaryFormatter();
   Stream stream = new FileStream("MyFile.bin", FileMode.Open, FileAccess.Read, FileShare.Read);
   MyObject obj = (MyObject)formatter.Deserialize(stream);
   stream.Close();




http://msdn.microsoft.com/en-us/library/72hyey7b(v=vs.80).aspx
XML serialization
   public class MyObject
   {
           public int n1 = 0;
           public int n2 = 0;
           public String str = null;
   }


   Serizalization
   MyObject obj = new MyObject();
   obj.n1 = 1;
   obj.n2 = 24;
   obj.str = "Some String";
   XmlSerializer serializer = new XmlSerializer(typeof(MyObject));
   Stream stream = new FileStream("MyFile.bin", FileMode.Create, FileAccess.Write, FileShare.None);
   serializer.Serialize(stream, obj);
   stream.Close();

   Deserizalization
   XmlSerializer serializer = new XmlSerializer(typeof(MyObject));
   Stream stream = new FileStream("MyFile.bin", FileMode.Open, FileAccess.Read, FileShare.Read);
   MyObject obj = (MyObject)serializer.Deserialize(stream);
   stream.Close();




http://msdn.microsoft.com/en-us/library/90c86ass(v=vs.80).aspx
The end
Tortoise SVN




http://tortoisesvn.net/

Más contenido relacionado

La actualidad más candente

Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDBantoinegirbal
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDBAlex Bilbie
 
2011 Mongo FR - MongoDB introduction
2011 Mongo FR - MongoDB introduction2011 Mongo FR - MongoDB introduction
2011 Mongo FR - MongoDB introductionantoinegirbal
 
"Solr Update" at code4lib '13 - Chicago
"Solr Update" at code4lib '13 - Chicago"Solr Update" at code4lib '13 - Chicago
"Solr Update" at code4lib '13 - ChicagoErik Hatcher
 
MongoDB: Easy Java Persistence with Morphia
MongoDB: Easy Java Persistence with MorphiaMongoDB: Easy Java Persistence with Morphia
MongoDB: Easy Java Persistence with MorphiaScott Hernandez
 
Webinar: Data Modeling Examples in the Real World
Webinar: Data Modeling Examples in the Real WorldWebinar: Data Modeling Examples in the Real World
Webinar: Data Modeling Examples in the Real WorldMongoDB
 
Talk about ReactiveMongo at MSUG May
Talk about ReactiveMongo at MSUG MayTalk about ReactiveMongo at MSUG May
Talk about ReactiveMongo at MSUG MayAndrey Neverov
 
Data Modeling for the Real World
Data Modeling for the Real WorldData Modeling for the Real World
Data Modeling for the Real WorldMike Friedman
 
MongoDB Advanced Topics
MongoDB Advanced TopicsMongoDB Advanced Topics
MongoDB Advanced TopicsCésar Rodas
 
NoSQL store everyone ignored - Postgres Conf 2021
NoSQL store everyone ignored - Postgres Conf 2021NoSQL store everyone ignored - Postgres Conf 2021
NoSQL store everyone ignored - Postgres Conf 2021Zohaib Hassan
 
Data Modeling Deep Dive
Data Modeling Deep DiveData Modeling Deep Dive
Data Modeling Deep DiveMongoDB
 

La actualidad más candente (20)

File-Data structure
File-Data structure File-Data structure
File-Data structure
 
Tthornton code4lib
Tthornton code4libTthornton code4lib
Tthornton code4lib
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Python Files
Python FilesPython Files
Python Files
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
2011 Mongo FR - MongoDB introduction
2011 Mongo FR - MongoDB introduction2011 Mongo FR - MongoDB introduction
2011 Mongo FR - MongoDB introduction
 
Python and MongoDB
Python and MongoDBPython and MongoDB
Python and MongoDB
 
MongoDB
MongoDBMongoDB
MongoDB
 
MongoDB (Advanced)
MongoDB (Advanced)MongoDB (Advanced)
MongoDB (Advanced)
 
"Solr Update" at code4lib '13 - Chicago
"Solr Update" at code4lib '13 - Chicago"Solr Update" at code4lib '13 - Chicago
"Solr Update" at code4lib '13 - Chicago
 
MongoDB: Easy Java Persistence with Morphia
MongoDB: Easy Java Persistence with MorphiaMongoDB: Easy Java Persistence with Morphia
MongoDB: Easy Java Persistence with Morphia
 
Webinar: Data Modeling Examples in the Real World
Webinar: Data Modeling Examples in the Real WorldWebinar: Data Modeling Examples in the Real World
Webinar: Data Modeling Examples in the Real World
 
Talk about ReactiveMongo at MSUG May
Talk about ReactiveMongo at MSUG MayTalk about ReactiveMongo at MSUG May
Talk about ReactiveMongo at MSUG May
 
MongoDB and Python
MongoDB and PythonMongoDB and Python
MongoDB and Python
 
Java File I/O
Java File I/OJava File I/O
Java File I/O
 
Data Modeling for the Real World
Data Modeling for the Real WorldData Modeling for the Real World
Data Modeling for the Real World
 
MongoDB Advanced Topics
MongoDB Advanced TopicsMongoDB Advanced Topics
MongoDB Advanced Topics
 
NoSQL store everyone ignored - Postgres Conf 2021
NoSQL store everyone ignored - Postgres Conf 2021NoSQL store everyone ignored - Postgres Conf 2021
NoSQL store everyone ignored - Postgres Conf 2021
 
CouchDB-Lucene
CouchDB-LuceneCouchDB-Lucene
CouchDB-Lucene
 
Data Modeling Deep Dive
Data Modeling Deep DiveData Modeling Deep Dive
Data Modeling Deep Dive
 

Similar a C# standard library classes

03 standard class library
03 standard class library03 standard class library
03 standard class libraryeleksdev
 
Migrating from matlab to python
Migrating from matlab to pythonMigrating from matlab to python
Migrating from matlab to pythonActiveState
 
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!Daniel Cousineau
 
Introduction to libre « fulltext » technology
Introduction to libre « fulltext » technologyIntroduction to libre « fulltext » technology
Introduction to libre « fulltext » technologyRobert Viseur
 
SDEC2011 NoSQL concepts and models
SDEC2011 NoSQL concepts and modelsSDEC2011 NoSQL concepts and models
SDEC2011 NoSQL concepts and modelsKorea Sdec
 
SMS Spam Filter Design Using R: A Machine Learning Approach
SMS Spam Filter Design Using R: A Machine Learning ApproachSMS Spam Filter Design Using R: A Machine Learning Approach
SMS Spam Filter Design Using R: A Machine Learning ApproachReza Rahimi
 
An Introduction to gensim: "Topic Modelling for Humans"
An Introduction to gensim: "Topic Modelling for Humans"An Introduction to gensim: "Topic Modelling for Humans"
An Introduction to gensim: "Topic Modelling for Humans"sandinmyjoints
 
Hadoop Overview & Architecture
Hadoop Overview & Architecture  Hadoop Overview & Architecture
Hadoop Overview & Architecture EMC
 
Process and Threads in Linux - PPT
Process and Threads in Linux - PPTProcess and Threads in Linux - PPT
Process and Threads in Linux - PPTQUONTRASOLUTIONS
 
Hadoop Tutorial with @techmilind
Hadoop Tutorial with @techmilindHadoop Tutorial with @techmilind
Hadoop Tutorial with @techmilindEMC
 
Cascading introduction
Cascading introductionCascading introduction
Cascading introductionAlex Su
 
AI與大數據數據處理 Spark實戰(20171216)
AI與大數據數據處理 Spark實戰(20171216)AI與大數據數據處理 Spark實戰(20171216)
AI與大數據數據處理 Spark實戰(20171216)Paul Chao
 
MongoDB at ZPUGDC
MongoDB at ZPUGDCMongoDB at ZPUGDC
MongoDB at ZPUGDCMike Dirolf
 
Happy Go Programming
Happy Go ProgrammingHappy Go Programming
Happy Go ProgrammingLin Yo-An
 
Using existing language skillsets to create large-scale, cloud-based analytics
Using existing language skillsets to create large-scale, cloud-based analyticsUsing existing language skillsets to create large-scale, cloud-based analytics
Using existing language skillsets to create large-scale, cloud-based analyticsMicrosoft Tech Community
 
2016 bioinformatics i_bio_python_wimvancriekinge
2016 bioinformatics i_bio_python_wimvancriekinge2016 bioinformatics i_bio_python_wimvancriekinge
2016 bioinformatics i_bio_python_wimvancriekingeProf. Wim Van Criekinge
 
2015 bioinformatics python_io_wim_vancriekinge
2015 bioinformatics python_io_wim_vancriekinge2015 bioinformatics python_io_wim_vancriekinge
2015 bioinformatics python_io_wim_vancriekingeProf. Wim Van Criekinge
 
What is new in CFEngine 3.6
What is new in CFEngine 3.6What is new in CFEngine 3.6
What is new in CFEngine 3.6RUDDER
 

Similar a C# standard library classes (20)

03 standard class library
03 standard class library03 standard class library
03 standard class library
 
Migrating from matlab to python
Migrating from matlab to pythonMigrating from matlab to python
Migrating from matlab to python
 
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
 
Introduction to libre « fulltext » technology
Introduction to libre « fulltext » technologyIntroduction to libre « fulltext » technology
Introduction to libre « fulltext » technology
 
SDEC2011 NoSQL concepts and models
SDEC2011 NoSQL concepts and modelsSDEC2011 NoSQL concepts and models
SDEC2011 NoSQL concepts and models
 
Python redis talk
Python redis talkPython redis talk
Python redis talk
 
SMS Spam Filter Design Using R: A Machine Learning Approach
SMS Spam Filter Design Using R: A Machine Learning ApproachSMS Spam Filter Design Using R: A Machine Learning Approach
SMS Spam Filter Design Using R: A Machine Learning Approach
 
An Introduction to gensim: "Topic Modelling for Humans"
An Introduction to gensim: "Topic Modelling for Humans"An Introduction to gensim: "Topic Modelling for Humans"
An Introduction to gensim: "Topic Modelling for Humans"
 
Hadoop Overview & Architecture
Hadoop Overview & Architecture  Hadoop Overview & Architecture
Hadoop Overview & Architecture
 
Process and Threads in Linux - PPT
Process and Threads in Linux - PPTProcess and Threads in Linux - PPT
Process and Threads in Linux - PPT
 
Hadoop Tutorial with @techmilind
Hadoop Tutorial with @techmilindHadoop Tutorial with @techmilind
Hadoop Tutorial with @techmilind
 
Cascading introduction
Cascading introductionCascading introduction
Cascading introduction
 
Hadoop london
Hadoop londonHadoop london
Hadoop london
 
AI與大數據數據處理 Spark實戰(20171216)
AI與大數據數據處理 Spark實戰(20171216)AI與大數據數據處理 Spark實戰(20171216)
AI與大數據數據處理 Spark實戰(20171216)
 
MongoDB at ZPUGDC
MongoDB at ZPUGDCMongoDB at ZPUGDC
MongoDB at ZPUGDC
 
Happy Go Programming
Happy Go ProgrammingHappy Go Programming
Happy Go Programming
 
Using existing language skillsets to create large-scale, cloud-based analytics
Using existing language skillsets to create large-scale, cloud-based analyticsUsing existing language skillsets to create large-scale, cloud-based analytics
Using existing language skillsets to create large-scale, cloud-based analytics
 
2016 bioinformatics i_bio_python_wimvancriekinge
2016 bioinformatics i_bio_python_wimvancriekinge2016 bioinformatics i_bio_python_wimvancriekinge
2016 bioinformatics i_bio_python_wimvancriekinge
 
2015 bioinformatics python_io_wim_vancriekinge
2015 bioinformatics python_io_wim_vancriekinge2015 bioinformatics python_io_wim_vancriekinge
2015 bioinformatics python_io_wim_vancriekinge
 
What is new in CFEngine 3.6
What is new in CFEngine 3.6What is new in CFEngine 3.6
What is new in CFEngine 3.6
 

Más de Victor Matyushevskyy (20)

Design patterns part 2
Design patterns part 2Design patterns part 2
Design patterns part 2
 
Design patterns part 1
Design patterns part 1Design patterns part 1
Design patterns part 1
 
Multithreading and parallelism
Multithreading and parallelismMultithreading and parallelism
Multithreading and parallelism
 
Mobile applications development
Mobile applications developmentMobile applications development
Mobile applications development
 
Service oriented programming
Service oriented programmingService oriented programming
Service oriented programming
 
ASP.Net MVC
ASP.Net MVCASP.Net MVC
ASP.Net MVC
 
ASP.Net part 2
ASP.Net part 2ASP.Net part 2
ASP.Net part 2
 
Java script + extjs
Java script + extjsJava script + extjs
Java script + extjs
 
ASP.Net basics
ASP.Net basics ASP.Net basics
ASP.Net basics
 
Automated testing
Automated testingAutomated testing
Automated testing
 
Основи Баз даних та MS SQL Server
Основи Баз даних та MS SQL ServerОснови Баз даних та MS SQL Server
Основи Баз даних та MS SQL Server
 
Usability
UsabilityUsability
Usability
 
Windows forms
Windows formsWindows forms
Windows forms
 
Practices
PracticesPractices
Practices
 
06.1 .Net memory management
06.1 .Net memory management06.1 .Net memory management
06.1 .Net memory management
 
06 LINQ
06 LINQ06 LINQ
06 LINQ
 
05 functional programming
05 functional programming05 functional programming
05 functional programming
 
#3 Об'єктно орієнтоване програмування (ч. 2)
#3 Об'єктно орієнтоване програмування (ч. 2)#3 Об'єктно орієнтоване програмування (ч. 2)
#3 Об'єктно орієнтоване програмування (ч. 2)
 
#2 Об'єктно орієнтоване програмування (ч. 1)
#2 Об'єктно орієнтоване програмування (ч. 1)#2 Об'єктно орієнтоване програмування (ч. 1)
#2 Об'єктно орієнтоване програмування (ч. 1)
 
#1 C# basics
#1 C# basics#1 C# basics
#1 C# basics
 

Último

Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...amber724300
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfAarwolf Industries LLC
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFMichael Gough
 
Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentMahmoud Rabie
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialJoão Esperancinha
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 

Último (20)

Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdf
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDF
 
Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career Development
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorial
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 

C# standard library classes

  • 2. Зміст 1. Що таке Generic? Extension methods. 2. Math 3. DateTime, TimeSpan 4. Regex 5. Колекції. System.Collections, System.Collections.Generic. 6. Nullable<T>, “type?” 7. Path 8. DriveInfo 9. Directory 10. File 11. Encodings 12. Streams 13. Serializationdeserializations
  • 3. Generics • Generic methods: • FirstOrDefault<T>(T[] array) • FirstOrDefault<T>(T[] array, T defaultValue) • Type inference: • int first = FirstOrDefault(new[] {3, 2, 1}); • default(T) expression • Type constraints: • Base type, class, struct, new() • Generic types: • Example: List<T> http://msdn.microsoft.com/en-us/library/ms379564(v=vs.80).aspx
  • 4. Extension methods Simply static methods Used for convenience http://msdn.microsoft.com/en-us/library/bb383977.aspx
  • 5. Math • Math.Abs(number) • Math.Pow(number) • Math.Sin(angle) • Math.Cos(angle) • Math.Max(number1, number2) • Math.Min(number1, number2) • … http://msdn.microsoft.com/en-us/library/system.math.aspx
  • 6. DateTime • DateTime – представляє значення дати та часу. • DateTime.Add(timeSpan) • DateTime.AddDay(number)…. • DateTime.ToString(format) (hh:mm:ss) • ToLocalTime() • ToUniversalTime() • DateTime.Now • DateTime.UtcNow • … • TimeSpan – представляє інтервали дати та часу. • TimeSpan.TotalMilliseconds • TimeSpan.Days • TimeSpan.TotalDays • … http://msdn.microsoft.com/en-us/library/system.datetime.aspx - DateTime http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx - Custom DateTime Formats
  • 7. Regex Email pattern: “b[A-Z0-9._%-]+@[A-Z0-9.-]+.[A-Z]{2,4}b” • Regex.IsMatch(pattern, string) • Regex.Replace(pattern, string, newValue) http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.aspx
  • 8. Collections Collections: • Hashtable • ArrayList • Queue • Stack Collections.Generic: • Dictionary<TKey, TValue> • List<T> • Queue<T> • Stack<T> • LinkedList<T> http://msdn.microsoft.com/en-us/library/system.collections.aspx - Collections http://msdn.microsoft.com/en-us/library/0sbxh9x2.aspx - Collections.Generic
  • 9. Nullable<T> int? = Nullable<int> Useful properties: • HasValue • Value http://msdn.microsoft.com/en-us/library/b3h38hb0.aspx
  • 10. Path • Path.Combine(path1, path2) • Path.GetDirectoryName(path) • Path.GetFileName(path) • Path.GetExtension(path) • Path.GetFullPath(path) • Path.GetRandomFileName() • Path.GetTempFileName() • Path.GetTempPath() http://msdn.microsoft.com/en-us/library/system.io.path_methods.aspx
  • 11. DriveInfo • DriveInfo.GetDrives() • drive.DriveType {CDRom, Fixed, Unknown, Network, Removable ….} • drive.DriveFormat {NTFS, FAT32} • drive. AvailableFreeSpace http://msdn.microsoft.com/en-us/library/system.io.driveinfo.aspx
  • 12. Directory • Directory.Create(folderPath) • Directory.Move(folderPath, destinationPath) • Directory.Delete(folderPath) && Directory.Delete(folderPath, true/*recursive*/) • Directory.Exists(folderPath) • Directory.GetFiles(folderPath, [search pattern]) http://msdn.microsoft.com/en-us/library/system.io.directory.aspx
  • 13. File • File.Create(filePath) • File.Move(filePath, filePathDestination) • File.Copy(filePath, filePathDestination) • File.Delete(filePath) • File.Exists(filePath) • File.WriteAllText(filePath, text) • File.WriteAllBytes(filePath, bytes) • File.AppendText(filePath, text) • File.ReadAllText(filePath) • File.ReadAllBytes(filePath) http://msdn.microsoft.com/en-us/library/system.io.file.aspx
  • 14. Encoding • Encoding.Default • Encoding.Unicode • Encoding.ASCII • Encoding.UTF32 • … • Encoding.Convert(sourceEncoding, destinationEncoding, bytes) • encoding.GetBytes(string) • encoding.GetString(bytes) http://msdn.microsoft.com/en-us/library/system.text.encoding.aspx
  • 15. Streams • stream.Read(data, offset, count) Stream • stream.Write(data, offset, count) • stream.Length CryptoStream • stream.Seek(offset, SeekOrigin) • stream.Close() MemoryStream FileStream • StreamWriter – easy way to write into text files. • StreamReader – easy way to read text from files. • FileStream – easy way to work with binary files. Create FileStream: • constructor (new FileStream(path, FileMode, FileAccess)) • File.Create • File.Open • File.Write http://msdn.microsoft.com/en-us/library/system.io.stream.aspx - Stream http://msdn.microsoft.com/en-us/library/system.io.filestream.aspx - FileStream
  • 16. Binary serialization [Serializable] public class MyObject { public int n1 = 0; public int n2 = 0; public String str = null; } Serizalization MyObject obj = new MyObject(); obj.n1 = 1; obj.n2 = 24; obj.str = "Some String"; IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream("MyFile.bin", FileMode.Create, FileAccess.Write, FileShare.None); formatter.Serialize(stream, obj); stream.Close(); Deserizalization IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream("MyFile.bin", FileMode.Open, FileAccess.Read, FileShare.Read); MyObject obj = (MyObject)formatter.Deserialize(stream); stream.Close(); http://msdn.microsoft.com/en-us/library/72hyey7b(v=vs.80).aspx
  • 17. XML serialization public class MyObject { public int n1 = 0; public int n2 = 0; public String str = null; } Serizalization MyObject obj = new MyObject(); obj.n1 = 1; obj.n2 = 24; obj.str = "Some String"; XmlSerializer serializer = new XmlSerializer(typeof(MyObject)); Stream stream = new FileStream("MyFile.bin", FileMode.Create, FileAccess.Write, FileShare.None); serializer.Serialize(stream, obj); stream.Close(); Deserizalization XmlSerializer serializer = new XmlSerializer(typeof(MyObject)); Stream stream = new FileStream("MyFile.bin", FileMode.Open, FileAccess.Read, FileShare.Read); MyObject obj = (MyObject)serializer.Deserialize(stream); stream.Close(); http://msdn.microsoft.com/en-us/library/90c86ass(v=vs.80).aspx

Notas del editor

  1. Важливість збереження UTCБаг з збереженням тільки дати. (ЮТС і потім проблема конвертацією до ЛокалТайм)
  2. The objects used as keys by a Hashtable are required to override the Object.GetHashCode method (or the IHashCodeProvider interface) and the Object.Equals method (or the IComparer interface).
  3. Path.Combine(“c:\\folder1\\”, “\\folder2\\fileName.txt”)GetDirectoryName(&apos;C:\\MyDir\\MySubDir\\myfile.ext&apos;) returns &apos;C:\\MyDir\\MySubDir‘GetFileName(&apos;C:\\mydir\\myfile.ext&apos;) returns &apos;myfile.ext‘// GetFullPath(&apos;mydir&apos;) returns &apos;C:\\temp\\Demo\\mydir&apos;// GetFullPath(&apos;\\mydir&apos;) returns &apos;C:\\mydir&apos;
  4. Rename - move
  5. File.Create returns Stream!Rename - move
  6. fs.Seek(offset, SeekOrigin.Begin)fs.Write(data, 0, data.length)
  7. Приавила серіалізаціїАтрибув [Serializable]Public\\private\\protected клас
  8. Приавила серіалізаціїДефолтний конструкторpublic класpublic проперті\\філдиЯкщо під час десеріалізації не знаходиться властивість у даних, то в об’єкті вона буде null