SlideShare uma empresa Scribd logo
1 de 19
Стандартна
бібліотека класів 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/

Mais conteúdo relacionado

Mais procurados

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
 

Mais procurados (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
 

Semelhante 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
 

Semelhante 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
 

Mais 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

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 

Último (20)

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 

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 do 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