using System.IO; ... string filePath = @"C:\Users\JohnDoe\Documents\example.txt"; string content = File.ReadAllText(filePath); Console.WriteLine(content);
using System.Data.SqlClient; ... string connectionString = "Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;"; SqlConnection connection = new SqlConnection(connectionString); SqlCommand command = new SqlCommand("SELECT * FROM MyTable", connection); SqlDataReader reader = command.ExecuteReader(); while(reader.Read()) { Console.WriteLine(reader.GetString(0)); }
using System.Web.SessionState; ... public class MyHttpHandler : IHttpHandler, IRequiresSessionState { public void ProcessRequest(HttpContext context) { string sessionVal = (string)context.Session["myVariable"]; context.Response.Write("Session value: " + sessionVal); } public bool IsReusable { get { return false; } } }Overall, package libraries in C# Assembly make it easy to use pre-built functionality in your applications, saving development time and effort.