Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Using The .NET Framework

683 views

Published on

Explore basic file IO operations, learn how to work with strings and see how to work with dates and times in the .NET Framework.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Using The .NET Framework

  1. 1. Using the .NET Framework Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  2. 2. Objectives Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  3. 3. Objectives • Review using .NET Framework classes Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  4. 4. Objectives • Review using .NET Framework classes • Explore basic file IO operations Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  5. 5. Objectives • Review using .NET Framework classes • Explore basic file IO operations • Learn how to work with strings Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  6. 6. Objectives • Review using .NET Framework classes • Explore basic file IO operations • Learn how to work with strings • See how to work with dates and times Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  7. 7. .NET Framework Base Class Library Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  8. 8. .NET Framework Base Class Library • BCL consists of classes that provide base functionality for .NET Framework Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  9. 9. .NET Framework Base Class Library • BCL consists of classes that provide base functionality for .NET Framework  Many classes that make your life as a developer easier Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  10. 10. .NET Framework Base Class Library • BCL consists of classes that provide base functionality for .NET Framework  Many classes that make your life as a developer easier  Library of classes used by all .NET applications Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  11. 11. .NET Framework Base Class Library • BCL consists of classes that provide base functionality for .NET Framework  Many classes that make your life as a developer easier  Library of classes used by all .NET applications • Contains large number of classes (blocks of functionality, including properties, methods, and events) Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  12. 12. .NET Framework Base Class Library • BCL consists of classes that provide base functionality for .NET Framework  Many classes that make your life as a developer easier  Library of classes used by all .NET applications • Contains large number of classes (blocks of functionality, including properties, methods, and events) • Namespaces group classes into common blocks of functionality Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  13. 13. Some BCL Namespaces Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  14. 14. Some BCL Namespaces • System Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  15. 15. Some BCL Namespaces • System • System.Data Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  16. 16. Some BCL Namespaces • System • System.Data • System.Diagnostics Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  17. 17. Some BCL Namespaces • System • System.Data • System.Diagnostics • System.Globalization Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  18. 18. Some BCL Namespaces • System • System.Data • System.Diagnostics • System.Globalization • System.IO Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  19. 19. Some BCL Namespaces • System • System.Data • System.Diagnostics • System.Globalization • System.IO • System.Text Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  20. 20. Some BCL Namespaces • System • System.Data • System.Diagnostics • System.Globalization • System.IO • System.Text • System.Text.RegularExpressions Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  21. 21. Some BCL Namespaces • System • System.Data • System.Diagnostics • System.Globalization • System.IO • System.Text • System.Text.RegularExpressions • System.Web Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  22. 22. Some BCL Namespaces • System • System.Data • System.Diagnostics • System.Globalization • System.IO • System.Text • System.Text.RegularExpressions • System.Web • System.Windows.Forms Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  23. 23. Using .NET Framework Classes Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  24. 24. Using .NET Framework Classes • Code you write in applications will be a mix of code that is specific to a language and code that uses .NET Framework classes Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  25. 25. Using .NET Framework Classes • Code you write in applications will be a mix of code that is specific to a language and code that uses .NET Framework classesDim amount As Decimal = 45.61DDim dollars, cents As Decimaldollars = Decimal.Truncate(amount)cents = amount - dollarsConsole.WriteLine( _ "The restaurant bill is {0:C}", _ amount)Console.WriteLine( _ "You pay the {0:C} and " & _ "Ill pay the {1:C}", _ dollars, cents) Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  26. 26. Using .NET Framework Classes • Code you write in applications will be a mix of code that is specific to a language and code that uses .NET Framework classesDim amount As Decimal = 45.61D decimal amount = 45.61M;Dim dollars, cents As Decimal decimal dollars, cents;dollars = Decimal.Truncate(amount) dollars = decimal.Truncate(amount);cents = amount - dollars cents = amount - collars;Console.WriteLine( _ Console.WriteLine( "The restaurant bill is {0:C}", _ "The restaurant bill is {0:C}", amount) amount);Console.WriteLine( _ Console.WriteLine( "You pay the {0:C} and " & _ "You pay the {0:C} and " + "Ill pay the {1:C}", _ "Ill pay the {1:C}", dollars, cents) dollars, cents); Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  27. 27. Generating Random Numbers Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  28. 28. Generating Random Numbers • Use Random class to generate a series of random numbers Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  29. 29. Generating Random Numbers • Use Random class to generate a series of random numbers  Generated random numbers start with seed value Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  30. 30. Generating Random Numbers • Use Random class to generate a series of random numbers  Generated random numbers start with seed value  Specify seed value or use default seed value Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  31. 31. Generating Random Numbers • Use Random class to generate a series of random numbers  Generated random numbers start with seed value  Specify seed value or use default seed value • Next generates the next random number in a sequence Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  32. 32. Getting Information about the Computer Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  33. 33. Getting Information about the Computer • Environment class provides information on the computer and the environment in which the computer is running Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  34. 34. Getting Information about the Computer • Environment class provides information on the computer and the environment in which the computer is running • Properties Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  35. 35. Getting Information about the Computer • Environment class provides information on the computer and the environment in which the computer is running • Properties  MachineName returns name of computer Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  36. 36. Getting Information about the Computer • Environment class provides information on the computer and the environment in which the computer is running • Properties  MachineName returns name of computer  UserName returns name of user Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  37. 37. Getting Information about the Computer • Environment class provides information on the computer and the environment in which the computer is running • Properties  MachineName returns name of computer  UserName returns name of user  OSVersion returns operating system name and version Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  38. 38. Getting Information about the Computer • Environment class provides information on the computer and the environment in which the computer is running • Properties  MachineName returns name of computer  UserName returns name of user  OSVersion returns operating system name and version  CurrentDirectory returns program’s directory at runtime Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  39. 39. Getting Information about the Computer • Environment class provides information on the computer and the environment in which the computer is running • Properties  MachineName returns name of computer  UserName returns name of user  OSVersion returns operating system name and version  CurrentDirectory returns program’s directory at runtime  Version returns version of the CLR Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  40. 40. Getting Information about the Computer • Environment class provides information on the computer and the environment in which the computer is running • Properties  MachineName returns name of computer  UserName returns name of user  OSVersion returns operating system name and version  CurrentDirectory returns program’s directory at runtime  Version returns version of the CLR • Use GetFolderPath and SpecialFolder enumeration to refer to My Documents, desktop, etc. Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  41. 41. Working with XML Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  42. 42. Working with XML • System.Xml namespace contains classes that support reading and writing XML Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  43. 43. Working with XML • System.Xml namespace contains classes that support reading and writing XML • Quick review of XML Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  44. 44. Working with XML • System.Xml namespace contains classes that support reading and writing XML • Quick review of XML  XML documents are based on elements Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  45. 45. Working with XML • System.Xml namespace contains classes that support reading and writing XML • Quick review of XML  XML documents are based on elements  Element comprised of start tag, content, and end tag Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  46. 46. Working with XML • System.Xml namespace contains classes that support reading and writing XML • Quick review of XML  XML documents are based on elements  Element comprised of start tag, content, and end tag  Elements can contain other elements Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  47. 47. Working with XML • System.Xml namespace contains classes that support reading and writing XML • Quick review of XML  XML documents are based on elements  Element comprised of start tag, content, and end tag  Elements can contain other elements  Attributes contain information about elements Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  48. 48. Working with XML • System.Xml namespace contains classes that support reading and writing XML • Quick review of XML  XML documents are based on elements  Element comprised of start tag, content, and end tag  Elements can contain other elements  Attributes contain information about elements <chapters total = "2"> <chapter>Variables and Data Types</chapter> <chapter>Using the .NET Framework</chapter> </chapters> Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  49. 49. Writing XML Files Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  50. 50. Writing XML Files • Use XmlWriter class to write XML to file or in memory Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  51. 51. Writing XML Files • Use XmlWriter class to write XML to file or in memory  Use Create to create a new instance and pass the name of an XML file as a parameter Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  52. 52. Writing XML Files • Use XmlWriter class to write XML to file or in memory  Use Create to create a new instance and pass the name of an XML file as a parameter • Use XmlWriterSettings class to control how XML is written Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  53. 53. Writing XML Files • Use XmlWriter class to write XML to file or in memory  Use Create to create a new instance and pass the name of an XML file as a parameter • Use XmlWriterSettings class to control how XML is written  Indent specifies that elements should be indented Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  54. 54. Writing XML Files • Use XmlWriter class to write XML to file or in memory  Use Create to create a new instance and pass the name of an XML file as a parameter • Use XmlWriterSettings class to control how XML is written  Indent specifies that elements should be indented  IndentChars specifies the character to use Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  55. 55. Writing XML Files • Use XmlWriter class to write XML to file or in memory  Use Create to create a new instance and pass the name of an XML file as a parameter • Use XmlWriterSettings class to control how XML is written  Indent specifies that elements should be indented  IndentChars specifies the character to use  NewLineChars specifies the character for line breaks Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  56. 56. Writing XML Files Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  57. 57. Writing XML Files • WriteStartDocument writes XML declaration Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  58. 58. Writing XML Files • WriteStartDocument writes XML declaration <?xml version="1.0" encoding="utf-8" standalone="yes"?> Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  59. 59. Writing XML Files • WriteStartDocument writes XML declaration <?xml version="1.0" encoding="utf-8" standalone="yes"?> • WriteStartElement adds an XML tag Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  60. 60. Writing XML Files • WriteStartDocument writes XML declaration <?xml version="1.0" encoding="utf-8" standalone="yes"?> • WriteStartElement adds an XML tag <chapters> Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  61. 61. Writing XML Files • WriteStartDocument writes XML declaration <?xml version="1.0" encoding="utf-8" standalone="yes"?> • WriteStartElement adds an XML tag <chapters> • WriteEndElement adds a closing tag Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  62. 62. Writing XML Files • WriteStartDocument writes XML declaration <?xml version="1.0" encoding="utf-8" standalone="yes"?> • WriteStartElement adds an XML tag <chapters> • WriteEndElement adds a closing tag </chapters> Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  63. 63. Writing XML Files • WriteStartDocument writes XML declaration <?xml version="1.0" encoding="utf-8" standalone="yes"?> • WriteStartElement adds an XML tag <chapters> • WriteEndElement adds a closing tag </chapters> • WriteAttributeString writes an attribute and its value Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  64. 64. Writing XML Files • WriteStartDocument writes XML declaration <?xml version="1.0" encoding="utf-8" standalone="yes"?> • WriteStartElement adds an XML tag <chapters> • WriteEndElement adds a closing tag </chapters> • WriteAttributeString writes an attribute and its value <chapters total = "2“> Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  65. 65. Writing XML Files • WriteStartDocument writes XML declaration <?xml version="1.0" encoding="utf-8" standalone="yes"?> • WriteStartElement adds an XML tag <chapters> • WriteEndElement adds a closing tag </chapters> • WriteAttributeString writes an attribute and its value <chapters total = "2“> • WriteElement adds an element and its value Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  66. 66. Writing XML Files • WriteStartDocument writes XML declaration <?xml version="1.0" encoding="utf-8" standalone="yes"?> • WriteStartElement adds an XML tag <chapters> • WriteEndElement adds a closing tag </chapters> • WriteAttributeString writes an attribute and its value <chapters total = "2“> • WriteElement adds an element and its value <chapter>Using the .NET Framework</chapter> Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  67. 67. Reading XML Files Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  68. 68. Reading XML Files • Use XmlReader class to read XML from file or from memory Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  69. 69. Reading XML Files • Use XmlReader class to read XML from file or from memory  Use Create to create a new instance and pass name of XML file as parameter Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  70. 70. Reading XML Files • Use XmlReader class to read XML from file or from memory  Use Create to create a new instance and pass name of XML file as parameter • Read reads each node in the XML one at a time Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  71. 71. Reading XML Files • Use XmlReader class to read XML from file or from memory  Use Create to create a new instance and pass name of XML file as parameter • Read reads each node in the XML one at a time  Use NodeType to determine if a node is an element or text, etc. Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  72. 72. Reading XML Files • Use XmlReader class to read XML from file or from memory  Use Create to create a new instance and pass name of XML file as parameter • Read reads each node in the XML one at a time  Use NodeType to determine if a node is an element or text, etc. • ReadToFollowing reads through XML until it finds the next element with a specified name Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  73. 73. Reading XML Files • Use XmlReader class to read XML from file or from memory  Use Create to create a new instance and pass name of XML file as parameter • Read reads each node in the XML one at a time  Use NodeType to determine if a node is an element or text, etc. • ReadToFollowing reads through XML until it finds the next element with a specified name • ReadInnerXml reads the content of an Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  74. 74. File Input/Output Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  75. 75. File Input/Output • System.IO namespace contains classes for writing to and reading from files and for managing drives, directories, and files Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  76. 76. Writing to and Reading from Files Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  77. 77. Writing to and Reading from Files • StreamWriter class creates and writes to file Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  78. 78. Writing to and Reading from Files • StreamWriter class creates and writes to file  Write adds text to file Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  79. 79. Writing to and Reading from Files • StreamWriter class creates and writes to file  Write adds text to file  WriteLine adds text and line break to file Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  80. 80. Writing to and Reading from Files • StreamWriter class creates and writes to file  Write adds text to file  WriteLine adds text and line break to file • StreamReader class reads from file Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  81. 81. Writing to and Reading from Files • StreamWriter class creates and writes to file  Write adds text to file  WriteLine adds text and line break to file • StreamReader class reads from file  Read reads text from file Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  82. 82. Writing to and Reading from Files • StreamWriter class creates and writes to file  Write adds text to file  WriteLine adds text and line break to file • StreamReader class reads from file  Read reads text from file  ReadLine reads lines of text from file Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  83. 83. Managing Files Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  84. 84. Managing Files • FileInfo class contains methods for copying, moving, renaming, creating, opening, deleting, and appending to files Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  85. 85. Managing Files • FileInfo class contains methods for copying, moving, renaming, creating, opening, deleting, and appending to files • Exists returns true if file exists Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  86. 86. Managing Files • FileInfo class contains methods for copying, moving, renaming, creating, opening, deleting, and appending to files • Exists returns true if file exists • Create creates a file Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  87. 87. Managing Files • FileInfo class contains methods for copying, moving, renaming, creating, opening, deleting, and appending to files • Exists returns true if file exists • Create creates a file  Returns an instance of FileStream class Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  88. 88. Managing Files • FileInfo class contains methods for copying, moving, renaming, creating, opening, deleting, and appending to files • Exists returns true if file exists • Create creates a file  Returns an instance of FileStream class o Use AppendText to add text to a file Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  89. 89. Managing Files • FileInfo class contains methods for copying, moving, renaming, creating, opening, deleting, and appending to files • Exists returns true if file exists • Create creates a file  Returns an instance of FileStream class o Use AppendText to add text to a file o Use CreateText to add text after removing existing text Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  90. 90. Managing Files • FileInfo class contains methods for copying, moving, renaming, creating, opening, deleting, and appending to files • Exists returns true if file exists • Create creates a file  Returns an instance of FileStream class o Use AppendText to add text to a file o Use CreateText to add text after removing existing text o Both of these return an instance of StreamWriter class Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  91. 91. Managing Files • FileInfo class contains methods for copying, moving, renaming, creating, opening, deleting, and appending to files • Exists returns true if file exists • Create creates a file  Returns an instance of FileStream class o Use AppendText to add text to a file o Use CreateText to add text after removing existing text o Both of these return an instance of StreamWriter class • Use Write and WriteLine to write text to a file Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  92. 92. Managing Files Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  93. 93. Managing Files • FileInfo properties to retrieve file information Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  94. 94. Managing Files • FileInfo properties to retrieve file information  Name returns file name Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  95. 95. Managing Files • FileInfo properties to retrieve file information  Name returns file name  FullName returns full path including file name Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  96. 96. Managing Files • FileInfo properties to retrieve file information  Name returns file name  FullName returns full path including file name  Length returns file size Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  97. 97. Managing Files • FileInfo properties to retrieve file information  Name returns file name  FullName returns full path including file name  Length returns file size  IsReadOnly returns true if file is read-only Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  98. 98. Managing Files • FileInfo properties to retrieve file information  Name returns file name  FullName returns full path including file name  Length returns file size  IsReadOnly returns true if file is read-only  CreationTime returns when file was created Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  99. 99. Managing Files • FileInfo properties to retrieve file information  Name returns file name  FullName returns full path including file name  Length returns file size  IsReadOnly returns true if file is read-only  CreationTime returns when file was created  LastAccessTime returns when file was last accessed Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  100. 100. Managing Files • FileInfo properties to retrieve file information  Name returns file name  FullName returns full path including file name  Length returns file size  IsReadOnly returns true if file is read-only  CreationTime returns when file was created  LastAccessTime returns when file was last accessed • CopyTo copies a file Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  101. 101. Managing Directories Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  102. 102. Managing Directories • DirectoryInfo class contains methods for creating, moving, and deleting directories, as well as getting a list of files in the directory Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  103. 103. Managing Directories • DirectoryInfo class contains methods for creating, moving, and deleting directories, as well as getting a list of files in the directory • Exists returns true if a directory exists Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  104. 104. Managing Directories • DirectoryInfo class contains methods for creating, moving, and deleting directories, as well as getting a list of files in the directory • Exists returns true if a directory exists • Create creates a directory Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  105. 105. Managing Directories • DirectoryInfo class contains methods for creating, moving, and deleting directories, as well as getting a list of files in the directory • Exists returns true if a directory exists • Create creates a directory • Delete removes a directory Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  106. 106. Managing Directories • DirectoryInfo class contains methods for creating, moving, and deleting directories, as well as getting a list of files in the directory • Exists returns true if a directory exists • Create creates a directory • Delete removes a directory • Name returns the name of a directory Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  107. 107. Managing Directories • DirectoryInfo class contains methods for creating, moving, and deleting directories, as well as getting a list of files in the directory • Exists returns true if a directory exists • Create creates a directory • Delete removes a directory • Name returns the name of a directory • FullName returns the full path and name of a directory Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  108. 108. Getting Information from Drives Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  109. 109. Getting Information from Drives • DriveInfo class returns information from a drive Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  110. 110. Getting Information from Drives • DriveInfo class returns information from a drive • GetDrives returns a list of all drives on a computer Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  111. 111. Getting Information from Drives • DriveInfo class returns information from a drive • GetDrives returns a list of all drives on a computer • Properties to view drive information Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  112. 112. Getting Information from Drives • DriveInfo class returns information from a drive • GetDrives returns a list of all drives on a computer • Properties to view drive information  Name returns drive name Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  113. 113. Getting Information from Drives • DriveInfo class returns information from a drive • GetDrives returns a list of all drives on a computer • Properties to view drive information  Name returns drive name  DriveType returns drive type, e.g., Fixed, Network, CDRom Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  114. 114. Getting Information from Drives • DriveInfo class returns information from a drive • GetDrives returns a list of all drives on a computer • Properties to view drive information  Name returns drive name  DriveType returns drive type, e.g., Fixed, Network, CDRom  DriveFormat returns file system name, e.g., NTFS or FAT32 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  115. 115. Getting Information from Drives • DriveInfo class returns information from a drive • GetDrives returns a list of all drives on a computer • Properties to view drive information  Name returns drive name  DriveType returns drive type, e.g., Fixed, Network, CDRom  DriveFormat returns file system name, e.g., NTFS or FAT32  VolumeLabel returns volume label Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  116. 116. Getting Information from Drives • DriveInfo class returns information from a drive • GetDrives returns a list of all drives on a computer • Properties to view drive information  Name returns drive name  DriveType returns drive type, e.g., Fixed, Network, CDRom  DriveFormat returns file system name, e.g., NTFS or FAT32  VolumeLabel returns volume label  IsReady returns true if drive is ready for read or read/write operations Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  117. 117. Getting Information from Drives • DriveInfo class returns information from a drive • GetDrives returns a list of all drives on a computer • Properties to view drive information  Name returns drive name  DriveType returns drive type, e.g., Fixed, Network, CDRom  DriveFormat returns file system name, e.g., NTFS or FAT32  VolumeLabel returns volume label  IsReady returns true if drive is ready for read or read/write operations  TotalSize returns total storage capacity Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  118. 118. Getting Information from Drives • DriveInfo class returns information from a drive • GetDrives returns a list of all drives on a computer • Properties to view drive information  Name returns drive name  DriveType returns drive type, e.g., Fixed, Network, CDRom  DriveFormat returns file system name, e.g., NTFS or FAT32  VolumeLabel returns volume label  IsReady returns true if drive is ready for read or read/write operations  TotalSize returns total storage capacity  TotalFreeSpace returns total amount of free space available Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  119. 119. Working with Strings Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  120. 120. Working with Strings • Wide variety of tasks you might want to accomplish when working with strings Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  121. 121. Working with Strings • Wide variety of tasks you might want to accomplish when working with strings  Separate out first and last name from string representing someone’s full name Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  122. 122. Working with Strings • Wide variety of tasks you might want to accomplish when working with strings  Separate out first and last name from string representing someone’s full name  Convert string to all uppercase Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  123. 123. Working with Strings • Wide variety of tasks you might want to accomplish when working with strings  Separate out first and last name from string representing someone’s full name  Convert string to all uppercase  Concatenate two strings representing a first and last name and create a string containing a last name, followed by a comma, followed by a first name Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  124. 124. Working with Strings • Wide variety of tasks you might want to accomplish when working with strings  Separate out first and last name from string representing someone’s full name  Convert string to all uppercase  Concatenate two strings representing a first and last name and create a string containing a last name, followed by a comma, followed by a first name  Display a number in currency format, for example $9,999.99 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  125. 125. String Class Fields and Properties Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  126. 126. String Class Fields and Properties • Empty represents an empty string Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  127. 127. String Class Fields and Properties • Empty represents an empty string • Length returns the number of characters Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  128. 128. String Class Fields and Properties • Empty represents an empty string • Length returns the number of characters • Chars returns a character at a position in a string Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  129. 129. String Class Methods Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  130. 130. String Class Methods • String class includes methods for a variety of tasks Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  131. 131. String Class Methods • String class includes methods for a variety of tasks  Comparing two strings Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  132. 132. String Class Methods • String class includes methods for a variety of tasks  Comparing two strings  Searching for a string in another string Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  133. 133. String Class Methods • String class includes methods for a variety of tasks  Comparing two strings  Searching for a string in another string  Modifying all or some of a string Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  134. 134. String Class Methods • String class includes methods for a variety of tasks  Comparing two strings  Searching for a string in another string  Modifying all or some of a string  Extracting part of a string from a string Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  135. 135. String Class Methods • String class includes methods for a variety of tasks  Comparing two strings  Searching for a string in another string  Modifying all or some of a string  Extracting part of a string from a string  Formatting the display of a string Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  136. 136. Comparing Strings Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  137. 137. Comparing Strings • Compare takes as parameters two strings Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  138. 138. Comparing Strings • Compare takes as parameters two strings  Returns negative number if the first string is less than the second, 0 if they are equal, and a positive number if the first string is greater than the second Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  139. 139. Comparing Strings • Compare takes as parameters two strings  Returns negative number if the first string is less than the second, 0 if they are equal, and a positive number if the first string is greater than the second • Equals takes as parameters two strings Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  140. 140. Comparing Strings • Compare takes as parameters two strings  Returns negative number if the first string is less than the second, 0 if they are equal, and a positive number if the first string is greater than the second • Equals takes as parameters two strings  Returns true if two strings are equal Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  141. 141. Comparing Strings • Compare takes as parameters two strings  Returns negative number if the first string is less than the second, 0 if they are equal, and a positive number if the first string is greater than the second • Equals takes as parameters two strings  Returns true if two strings are equal • CompareTo method of a string takes as parameter a string to compare Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  142. 142. Comparing Strings • Compare takes as parameters two strings  Returns negative number if the first string is less than the second, 0 if they are equal, and a positive number if the first string is greater than the second • Equals takes as parameters two strings  Returns true if two strings are equal • CompareTo method of a string takes as parameter a string to compare  Returns a negative number if the first string is less than second, 0 if they are equal, and a positive Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  143. 143. Searching in Strings Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  144. 144. Searching in Strings • StartsWith, EndsWith, Contains and IndexOf all test for the existence of one string within another string Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  145. 145. Searching in Strings • StartsWith, EndsWith, Contains and IndexOf all test for the existence of one string within another string  All are methods of the first string and take the second string as the parameter Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  146. 146. Searching in Strings • StartsWith, EndsWith, Contains and IndexOf all test for the existence of one string within another string  All are methods of the first string and take the second string as the parameter  StartsWith, EndsWith, and Contains return true if the second string is found in the first string Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  147. 147. Searching in Strings • StartsWith, EndsWith, Contains and IndexOf all test for the existence of one string within another string  All are methods of the first string and take the second string as the parameter  StartsWith, EndsWith, and Contains return true if the second string is found in the first string  IndexOf returns an integer representing the starting point of the second string Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  148. 148. Modifying Strings Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  149. 149. Modifying Strings • Insert adds a string at a specified position Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  150. 150. Modifying Strings • Insert adds a string at a specified position • Remove removes all characters between two positions Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  151. 151. Modifying Strings • Insert adds a string at a specified position • Remove removes all characters between two positions  Specify the start position to remove all characters from the start to the end of a string Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  152. 152. Modifying Strings • Insert adds a string at a specified position • Remove removes all characters between two positions  Specify the start position to remove all characters from the start to the end of a string  Specify the start and end position to remove all characters from the start through the end position Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  153. 153. Modifying Strings • Insert adds a string at a specified position • Remove removes all characters between two positions  Specify the start position to remove all characters from the start to the end of a string  Specify the start and end position to remove all characters from the start through the end position • Replace replaces part of a string with another string Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  154. 154. Modifying Strings • Insert adds a string at a specified position • Remove removes all characters between two positions  Specify the start position to remove all characters from the start to the end of a string  Specify the start and end position to remove all characters from the start through the end position • Replace replaces part of a string with another string  Replace a character with another character Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  155. 155. Modifying Strings Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  156. 156. Modifying Strings • Trim eliminates white space from beginning and end Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  157. 157. Modifying Strings • Trim eliminates white space from beginning and end • TrimStart eliminates white space from beginning Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  158. 158. Modifying Strings • Trim eliminates white space from beginning and end • TrimStart eliminates white space from beginning • TrimEnd eliminates white space from end Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  159. 159. Modifying Strings • Trim eliminates white space from beginning and end • TrimStart eliminates white space from beginning • TrimEnd eliminates white space from end • PadLeft adds white space or character to beginning Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  160. 160. Modifying Strings • Trim eliminates white space from beginning and end • TrimStart eliminates white space from beginning • TrimEnd eliminates white space from end • PadLeft adds white space or character to beginning • PadRight adds white space or character to end Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  161. 161. Modifying Strings • Trim eliminates white space from beginning and end • TrimStart eliminates white space from beginning • TrimEnd eliminates white space from end • PadLeft adds white space or character to beginning • PadRight adds white space or character to end • ToUpper converts string to uppercase Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  162. 162. Extracting Strings Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  163. 163. Extracting Strings • Substring retrieves part of a string Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  164. 164. Extracting Strings • Substring retrieves part of a string  First parameter specifies position representing start of string you want to retrieve Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  165. 165. Extracting Strings • Substring retrieves part of a string  First parameter specifies position representing start of string you want to retrieve  Optional second parameter specifies length of string you want to retrieve Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  166. 166. Extracting Strings • Substring retrieves part of a string  First parameter specifies position representing start of string you want to retrieve  Optional second parameter specifies length of string you want to retrieve • Split retrieves multiple parts of a string Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  167. 167. Extracting Strings • Substring retrieves part of a string  First parameter specifies position representing start of string you want to retrieve  Optional second parameter specifies length of string you want to retrieve • Split retrieves multiple parts of a string  Takes as parameter an array containing characters used as delimiters, or separators (e.g. , or | or tab) Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  168. 168. Extracting Strings • Substring retrieves part of a string  First parameter specifies position representing start of string you want to retrieve  Optional second parameter specifies length of string you want to retrieve • Split retrieves multiple parts of a string  Takes as parameter an array containing characters used as delimiters, or separators (e.g. , or | or tab)  Returns an array containing parts of the string separated by characters listed in an array Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  169. 169. Formatting Strings Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  170. 170. Formatting Strings • Use format specifiers to control how a string is displayed Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  171. 171. Formatting Strings • Use format specifiers to control how a string is displayed • Formatting numbers Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  172. 172. Formatting Strings • Use format specifiers to control how a string is displayed • Formatting numbers  C or c displays as currency: $121,246,424.00 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  173. 173. Formatting Strings • Use format specifiers to control how a string is displayed • Formatting numbers  C or c displays as currency: $121,246,424.00  D or d displays a string as a decimal: 121246424 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  174. 174. Formatting Strings • Use format specifiers to control how a string is displayed • Formatting numbers  C or c displays as currency: $121,246,424.00  D or d displays a string as a decimal: 121246424  E or e displays in scientific (exponential) form: 1.212464E+008 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  175. 175. Formatting Strings • Use format specifiers to control how a string is displayed • Formatting numbers  C or c displays as currency: $121,246,424.00  D or d displays a string as a decimal: 121246424  E or e displays in scientific (exponential) form: 1.212464E+008  F or f displays as a fixed-point number: 121246424.00 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  176. 176. Formatting Strings • Use format specifiers to control how a string is displayed • Formatting numbers  C or c displays as currency: $121,246,424.00  D or d displays a string as a decimal: 121246424  E or e displays in scientific (exponential) form: 1.212464E+008  F or f displays as a fixed-point number: 121246424.00  G or g displays in general format: 121246424 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  177. 177. Formatting Strings • Use format specifiers to control how a string is displayed • Formatting numbers  C or c displays as currency: $121,246,424.00  D or d displays a string as a decimal: 121246424  E or e displays in scientific (exponential) form: 1.212464E+008  F or f displays as a fixed-point number: 121246424.00  G or g displays in general format: 121246424  N or n displays as a number: 121,246,424.00 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  178. 178. Formatting Strings Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  179. 179. Formatting Strings • Formatting dates Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  180. 180. Formatting Strings • Formatting dates  d displays in short date pattern: 1/1/2100 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  181. 181. Formatting Strings • Formatting dates  d displays in short date pattern: 1/1/2100  D displays in long date pattern: Friday, January 01, 2100 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  182. 182. Formatting Strings • Formatting dates  d displays in short date pattern: 1/1/2100  D displays in long date pattern: Friday, January 01, 2100  t displays in short time pattern: 12:00 AM Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  183. 183. Formatting Strings • Formatting dates  d displays in short date pattern: 1/1/2100  D displays in long date pattern: Friday, January 01, 2100  t displays in short time pattern: 12:00 AM  T displays in long time pattern: 12:00:00 AM Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  184. 184. Formatting Strings • Formatting dates  d displays in short date pattern: 1/1/2100  D displays in long date pattern: Friday, January 01, 2100  t displays in short time pattern: 12:00 AM  T displays in long time pattern: 12:00:00 AM  f displays in full date/time pattern (short time): Friday, January 01, 2100 12:00 AM Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  185. 185. Formatting Strings • Formatting dates  d displays in short date pattern: 1/1/2100  D displays in long date pattern: Friday, January 01, 2100  t displays in short time pattern: 12:00 AM  T displays in long time pattern: 12:00:00 AM  f displays in full date/time pattern (short time): Friday, January 01, 2100 12:00 AM  F displays in full date/time pattern (long time): Friday, January 01, 2100 12:00:00 AM Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  186. 186. Formatting Strings • Formatting dates  d displays in short date pattern: 1/1/2100  D displays in long date pattern: Friday, January 01, 2100  t displays in short time pattern: 12:00 AM  T displays in long time pattern: 12:00:00 AM  f displays in full date/time pattern (short time): Friday, January 01, 2100 12:00 AM  F displays in full date/time pattern (long time): Friday, January 01, 2100 12:00:00 AM  g displays in general date/time pattern (short time): 1/1/2100 12:00 AM Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  187. 187. Formatting Strings • Formatting dates  d displays in short date pattern: 1/1/2100  D displays in long date pattern: Friday, January 01, 2100  t displays in short time pattern: 12:00 AM  T displays in long time pattern: 12:00:00 AM  f displays in full date/time pattern (short time): Friday, January 01, 2100 12:00 AM  F displays in full date/time pattern (long time): Friday, January 01, 2100 12:00:00 AM  g displays in general date/time pattern (short time): 1/1/2100 12:00 AM  G displays in general date/time pattern (long time): 1/1/2100 12:00:00 AM Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  188. 188. Using the StringBuilder Class Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  189. 189. Using the StringBuilder Class • Strings are immutable so each time you use a string operator a new string is created Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  190. 190. Using the StringBuilder Class • Strings are immutable so each time you use a string operator a new string is created • StringBuilder is more efficient and represents one string in memory Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  191. 191. Using the StringBuilder Class • Strings are immutable so each time you use a string operator a new string is created • StringBuilder is more efficient and represents one string in memory • Append adds a string to the end of an existing string Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  192. 192. Using the StringBuilder Class • Strings are immutable so each time you use a string operator a new string is created • StringBuilder is more efficient and represents one string in memory • Append adds a string to the end of an existing string • AppendLine adds a string followed by a line break to an existing string Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  193. 193. Using the StringBuilder Class • Strings are immutable so each time you use a string operator a new string is created • StringBuilder is more efficient and represents one string in memory • Append adds a string to the end of an existing string • AppendLine adds a string followed by a line break to an existing string • Insert adds a string to an existing string at a specific position Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  194. 194. Using the StringBuilder Class • Strings are immutable so each time you use a string operator a new string is created • StringBuilder is more efficient and represents one string in memory • Append adds a string to the end of an existing string • AppendLine adds a string followed by a line break to an existing string • Insert adds a string to an existing string at a specific position • Replace replaces all occurrences of one string with another string Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  195. 195. Working with Dates and Times Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  196. 196. Working with Dates and Times • Dates and times are represented by DateTime structure Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  197. 197. Working with Dates and Times • Dates and times are represented by DateTime structure • Date and time intervals are represented by TimeSpan structure Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  198. 198. DateTime Structure Properties Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  199. 199. DateTime Structure Properties • Today returns current date Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  200. 200. DateTime Structure Properties • Today returns current date • Now returns current date and time Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  201. 201. DateTime Structure Properties • Today returns current date • Now returns current date and time • To determine the components of date or time use Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  202. 202. DateTime Structure Properties • Today returns current date • Now returns current date and time • To determine the components of date or time use  Date Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  203. 203. DateTime Structure Properties • Today returns current date • Now returns current date and time • To determine the components of date or time use  Date  Month Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  204. 204. DateTime Structure Properties • Today returns current date • Now returns current date and time • To determine the components of date or time use  Date  Month  Day Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  205. 205. DateTime Structure Properties • Today returns current date • Now returns current date and time • To determine the components of date or time use  Date  Month  Day  Year Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  206. 206. DateTime Structure Properties • Today returns current date • Now returns current date and time • To determine the components of date or time use  Date  Month  Day  Year  DayOfWeek Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  207. 207. DateTime Structure Properties • Today returns current date • Now returns current date and time • To determine the components of date or time use  Date  Month  Day  Year  DayOfWeek  DayOfYear Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  208. 208. DateTime Structure Properties • Today returns current date • Now returns current date and time • To determine the components of date or time use  Date  Month  Day  Year  DayOfWeek  DayOfYear  TimeOfDay Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  209. 209. DateTime Structure Properties • Today returns current date • Now returns current date and time • To determine the components of date or time use  Date  Month  Day  Year  DayOfWeek  DayOfYear  TimeOfDay  Hour Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  210. 210. DateTime Structure Properties • Today returns current date • Now returns current date and time • To determine the components of date or time use  Date  Month  Day  Year  DayOfWeek  DayOfYear  TimeOfDay  Hour  Minute Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  211. 211. DateTime Structure Properties • Today returns current date • Now returns current date and time • To determine the components of date or time use  Date  Month  Day  Year  DayOfWeek  DayOfYear  TimeOfDay  Hour  Minute  Second Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  212. 212. DateTime Structure Methods Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  213. 213. DateTime Structure Methods • To convert DateTime variable to string use Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  214. 214. DateTime Structure Methods • To convert DateTime variable to string use  ToLongDateString, displays date in long format Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  215. 215. DateTime Structure Methods • To convert DateTime variable to string use  ToLongDateString, displays date in long format  ToLongTimeString, displays time in long format Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  216. 216. DateTime Structure Methods • To convert DateTime variable to string use  ToLongDateString, displays date in long format  ToLongTimeString, displays time in long format  ToShortDateString, displays date in short format Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  217. 217. DateTime Structure Methods • To convert DateTime variable to string use  ToLongDateString, displays date in long format  ToLongTimeString, displays time in long format  ToShortDateString, displays date in short format  ToShortTimeString, displays time in short format Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  218. 218. DateTime Structure Methods • To convert DateTime variable to string use  ToLongDateString, displays date in long format  ToLongTimeString, displays time in long format  ToShortDateString, displays date in short format  ToShortTimeString, displays time in short format • To find date in future or past use Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  219. 219. DateTime Structure Methods • To convert DateTime variable to string use  ToLongDateString, displays date in long format  ToLongTimeString, displays time in long format  ToShortDateString, displays date in short format  ToShortTimeString, displays time in short format • To find date in future or past use  AddDays Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  220. 220. DateTime Structure Methods • To convert DateTime variable to string use  ToLongDateString, displays date in long format  ToLongTimeString, displays time in long format  ToShortDateString, displays date in short format  ToShortTimeString, displays time in short format • To find date in future or past use  AddDays  AddMonths Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  221. 221. DateTime Structure Methods • To convert DateTime variable to string use  ToLongDateString, displays date in long format  ToLongTimeString, displays time in long format  ToShortDateString, displays date in short format  ToShortTimeString, displays time in short format • To find date in future or past use  AddDays  AddMonths  AddYears Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  222. 222. DateTime Structure Methods • To convert DateTime variable to string use  ToLongDateString, displays date in long format  ToLongTimeString, displays time in long format  ToShortDateString, displays date in short format  ToShortTimeString, displays time in short format • To find date in future or past use  AddDays  AddMonths  AddYears  AddHours Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  223. 223. DateTime Structure Methods • To convert DateTime variable to string use  ToLongDateString, displays date in long format  ToLongTimeString, displays time in long format  ToShortDateString, displays date in short format  ToShortTimeString, displays time in short format • To find date in future or past use  AddDays  AddMonths  AddYears  AddHours  AddMinutes Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  224. 224. DateTime Structure Methods • To convert DateTime variable to string use  ToLongDateString, displays date in long format  ToLongTimeString, displays time in long format  ToShortDateString, displays date in short format  ToShortTimeString, displays time in short format • To find date in future or past use  AddDays  AddMonths  AddYears  AddHours  AddMinutes  AddSeconds Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  225. 225. Using the TimeSpan Structure Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  226. 226. Using the TimeSpan Structure • TimeSpan represents the duration of time measured in ticks (100 nanoseconds) Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  227. 227. Using the TimeSpan Structure • TimeSpan represents the duration of time measured in ticks (100 nanoseconds) • To determine the components of date or time use Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  228. 228. Using the TimeSpan Structure • TimeSpan represents the duration of time measured in ticks (100 nanoseconds) • To determine the components of date or time use  Days - # of whole days in interval Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  229. 229. Using the TimeSpan Structure • TimeSpan represents the duration of time measured in ticks (100 nanoseconds) • To determine the components of date or time use  Days - # of whole days in interval  Hours - # of whole hours in interval Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  230. 230. Using the TimeSpan Structure • TimeSpan represents the duration of time measured in ticks (100 nanoseconds) • To determine the components of date or time use  Days - # of whole days in interval  Hours - # of whole hours in interval  Minutes - # of whole minutes in interval Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  231. 231. Using the TimeSpan Structure • TimeSpan represents the duration of time measured in ticks (100 nanoseconds) • To determine the components of date or time use  Days - # of whole days in interval  Hours - # of whole hours in interval  Minutes - # of whole minutes in interval  Seconds - # of whole seconds in interval Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  232. 232. Using the TimeSpan Structure • TimeSpan represents the duration of time measured in ticks (100 nanoseconds) • To determine the components of date or time use  Days - # of whole days in interval  Hours - # of whole hours in interval  Minutes - # of whole minutes in interval  Seconds - # of whole seconds in interval  Milliseconds - # of whole milliseconds in interval Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  233. 233. Using the TimeSpan Structure • TimeSpan represents the duration of time measured in ticks (100 nanoseconds) • To determine the components of date or time use  Days - # of whole days in interval  Hours - # of whole hours in interval  Minutes - # of whole minutes in interval  Seconds - # of whole seconds in interval  Milliseconds - # of whole milliseconds in interval  TotalDays - # of whole and fractional days in interval Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  234. 234. Using the TimeSpan Structure • TimeSpan represents the duration of time measured in ticks (100 nanoseconds) • To determine the components of date or time use  Days - # of whole days in interval  Hours - # of whole hours in interval  Minutes - # of whole minutes in interval  Seconds - # of whole seconds in interval  Milliseconds - # of whole milliseconds in interval  TotalDays - # of whole and fractional days in interval  TotalHours - # of whole and fractional hours in interval Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  235. 235. Using the TimeSpan Structure • TimeSpan represents the duration of time measured in ticks (100 nanoseconds) • To determine the components of date or time use  Days - # of whole days in interval  Hours - # of whole hours in interval  Minutes - # of whole minutes in interval  Seconds - # of whole seconds in interval  Milliseconds - # of whole milliseconds in interval  TotalDays - # of whole and fractional days in interval  TotalHours - # of whole and fractional hours in interval  TotalMinutes - # of whole and fractional minutes in interval Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  236. 236. Using the TimeSpan Structure • TimeSpan represents the duration of time measured in ticks (100 nanoseconds) • To determine the components of date or time use  Days - # of whole days in interval  Hours - # of whole hours in interval  Minutes - # of whole minutes in interval  Seconds - # of whole seconds in interval  Milliseconds - # of whole milliseconds in interval  TotalDays - # of whole and fractional days in interval  TotalHours - # of whole and fractional hours in interval  TotalMinutes - # of whole and fractional minutes in interval  TotalSeconds - # of whole and fractional seconds in interval Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  237. 237. Learn More! Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  238. 238. Learn More!• This is an excerpt from a larger course. Visit www.learnnowonline.com for the full details! Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  239. 239. Learn More!• This is an excerpt from a larger course. Visit www.learnnowonline.com for the full details! Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  240. 240. Learn More!• This is an excerpt from a larger course. Visit www.learnnowonline.com for the full details!• Learn more about .NET on SlideShare: Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  241. 241. Learn More!• This is an excerpt from a larger course. Visit www.learnnowonline.com for the full details!• Learn more about .NET on SlideShare: • Getting Started with .NET Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  242. 242. Learn More!• This is an excerpt from a larger course. Visit www.learnnowonline.com for the full details!• Learn more about .NET on SlideShare: • Getting Started with .NET • .NET Variables and Data Types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company

×