Skip to content

Instantly share code, notes, and snippets.

@harshityadav95
harshityadav95 / Code.cs
Created July 29, 2016 12:22
Code to Insert data into the Excel File using C# application using Google Code ExcelLibrary
using ExcelLibrary.CompoundDocumentFormat;
using ExcelLibrary.SpreadSheet;
string file = "newdoc.xls";
Workbook workbook = new Workbook();
Worksheet worksheet = new Worksheet("First Sheet");
worksheet.Cells[0, 1] = new Cell((short)1);
worksheet.Cells[2, 0] = new Cell(9999999);
worksheet.Cells[3, 3] = new Cell((decimal)3.45);
worksheet.Cells[2, 2] = new Cell("Text string");
@harshityadav95
harshityadav95 / code.cs
Created July 29, 2016 12:25
C# code from Finsar Sqlite to create an Sqlite database and insert some values it no it and display them in a message box
// [snip] - As C# is purely object-oriented the following lines must be put into a class:
// We use these three SQLite objects:
SQLiteConnection sqlite_conn;
SQLiteCommand sqlite_cmd;
SQLiteDataReader sqlite_datareader;
// create a new database connection:
sqlite_conn = new SQLiteConnection("Data Source=database.db;Version=3;New=True;Compress=True;");
@harshityadav95
harshityadav95 / save_record_access
Created July 30, 2016 11:39
C# Save A Access Record into the database from the values accepted by the user .
try
{
obj1.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = obj1;
MessageBox.Show("Login Succesfull");
//Throwing exception when enteringg data into the same databse
//command.CommandText = "insert into empdata (ID,empname,phone,dob,password) values('" + textBox.Text + "','" + textBox1.Text + "','"+ textBox3.Text + "','"+ textBox4 .Text+ "','"+ textBox2.Text + "')";
@harshityadav95
harshityadav95 / code.cs
Created July 7, 2017 19:52
C# classes and Structures
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
namespace After001
{
internal class Program
{
private static void Main(string[] args)
{
@harshityadav95
harshityadav95 / code.cs
Created July 7, 2017 19:53
C# classes and Inheritance
using System;
namespace After002
{
internal class Program
{
private static void Main(string[] args)
{
var animals = new IAnimal[] {new Monkey(), new Dog()};
foreach (var animal in animals)
@harshityadav95
harshityadav95 / login left align
Created July 8, 2017 18:08
HTML code to align login box to the left
<div class="BookingTicketsLogin">
<div class="LoginBlockTop">
<div class="LoginBlock_TopLeft"></div>
<div class="LoginBlock_TopMid"></div>
<div class="LoginBlock_TopRight"></div>
</div>
<div class="LoginBlock">
<div class="LoginBlockDiv">
<h3>Login</h3><br>
<font style="color: red;"></font>
@harshityadav95
harshityadav95 / code.cs
Created July 8, 2017 20:06
Code Reflection in C#
using System;
using System.Reflection;
namespace After004
{
internal class Program
{
private static void Main(string[] args)
{
// without reflection
@harshityadav95
harshityadav95 / code.cs
Created July 8, 2017 20:36
Thread Pool in c#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace After017
{
class Program
@harshityadav95
harshityadav95 / code.cs
Last active December 12, 2020 14:33
Encryption in c#
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
namespace After024
{
internal class Program
@harshityadav95
harshityadav95 / code.cs
Created July 9, 2017 12:13
REST in c#
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using System.Xml;