Snippets Collections
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace smtp1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                // Create the email
                MailMessage mail = new MailMessage();
                mail.To.Add(TextBox1.Text);  // Recipient email (from input)
                mail.From = new MailAddress("helloeventplanner2025@gmail.com");
                mail.Subject = TextBox2.Text; // Subject from input
                mail.Body = TextBox3.Text;    // Body from input

                // Configure SMTP
                SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
                smtp.Credentials = new System.Net.NetworkCredential(
                    "helloeventplanner2025@gmail.com",
                    "lmrpnnsvmdlhexxp" // Gmail App Password
                );
                smtp.EnableSsl = true;

                // Send email
                smtp.Send(mail);

                Label1.Text = "✅ Email sent successfully!";
            }
            catch (Exception ex)
            {
                Label1.Text = "❌ Error: " + ex.Message;
            }
        }
    }
}












<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="smtp1.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            To&nbsp;&nbsp;
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            <br />
            Sub
            <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
            <br />
            Body
            <asp:TextBox ID="TextBox3" runat="server" Height="129px" Width="255px"></asp:TextBox>
            <br />
            <br />
            <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Send" />
        </div>
        <asp:Label ID="Label1" runat="server" Text="Status"></asp:Label>
    </form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;



namespace TASK11
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                MailMessage mail = new MailMessage();
                mail.To.Add(TextBox1.Text);
                mail.From = new MailAddress("youremail@domain.com"); // Replace with your email
                mail.Subject = TextBox2.Text;
                mail.Body = TextBox3.Text;

                SmtpClient smtp = new SmtpClient();
                smtp.Host = "smtp.gmail.com"; // Replace with your SMTP server
                smtp.Port = 587; // Replace with SMTP port
                smtp.Credentials = new System.Net.NetworkCredential("username", "password"); // Replace with your credentials
                smtp.EnableSsl = true;
                smtp.Send(mail);
                Label4.Text = "Email sent successfully!";
            }
            catch (Exception ex)
            {
                Label4.Text = "Error: " + ex.Message;
            }
        }
    }
    }
using System;


class Employee
{
    public string Name { get; set; }
    public int EmployeeID { get; set; }
    public double Salary { get; protected set; }

    public Employee(string name, int id)
    {
        Name = name;
        EmployeeID = id;
    }

    public virtual void DisplayDetails()
    {
        Console.WriteLine("Employee ID: " + EmployeeID);
        Console.WriteLine("Name: " + Name);
        Console.WriteLine("Salary: " + Salary);
    }
}


class FullTimeEmployee : Employee
{
    public double BasicSalary { get; set; }
    public int NumberOfDays { get; set; }
    public double HRA { get; set; }
    public double DA { get; set; }

    public FullTimeEmployee(string name, int id, double basicSalary, int numberOfDays, double hra, double da)
        : base(name, id)
    {
        BasicSalary = basicSalary;
        NumberOfDays = numberOfDays;
        HRA = hra;
        DA = da;
    }

    public void CalculateSalary()
    {
        Salary = (BasicSalary * NumberOfDays) + HRA + DA;
    }

    public override void DisplayDetails()
    {
        base.DisplayDetails();
        Console.WriteLine("Employee Type: Full-Time");
        Console.WriteLine("Basic Salary: " + BasicSalary);
        Console.WriteLine("Number of Days: " + NumberOfDays);
        Console.WriteLine("HRA: " + HRA);
        Console.WriteLine("DA: " + DA);
        Console.WriteLine();
    }
}


class PartTimeEmployee : Employee
{
    public double DailyWages { get; set; }
    public int NumberOfDays { get; set; }

    public PartTimeEmployee(string name, int id, double dailyWages, int numberOfDays)
        : base(name, id)
    {
        DailyWages = dailyWages;
        NumberOfDays = numberOfDays;
    }

    public void CalculateSalary()
    {
        Salary = DailyWages * NumberOfDays;
    }

    public override void DisplayDetails()
    {
        base.DisplayDetails();
        Console.WriteLine("Employee Type: Part-Time");
        Console.WriteLine("Daily Wages: " + DailyWages);
        Console.WriteLine("Number of Days: " + NumberOfDays);
        Console.WriteLine();
    }
}

class Program
{
    static void Main()
    {
        FullTimeEmployee fte = new FullTimeEmployee("Abhi", 101, 1000, 20, 500, 300);
        fte.CalculateSalary();
        fte.DisplayDetails();

        PartTimeEmployee pte = new PartTimeEmployee("Abh", 102, 500, 15);
        pte.CalculateSalary();
        pte.DisplayDetails();
    }
}

using System;
using System.Threading;
class Program
{
    public delegate int MathOperation(int a, int b);
    public static int Add(int a, int b)
    {
        Thread.Sleep(2000); 
        return a + b;
    }
    static void Main(string[] args)
    {
        Console.WriteLine("Main Started");
        MathOperation add = Add;
        Console.WriteLine("\nSynchronous call:");
        int syncResult = add(5, 3);
        Console.WriteLine($"Synchronous result: {syncResult}");
        Console.WriteLine("\nAsync call using BeginInvoke:");
        IAsyncResult asyncResult = add.BeginInvoke(20, 20, null, null);
        Console.WriteLine("Main thread continues to run...");
        int asyncResultValue = add.EndInvoke(asyncResult);
        Console.WriteLine($"Asynchronous result: {asyncResultValue}");
        Console.WriteLine("Main Ended");
    }
}
site1.master 

<!DOCTYPE html>
<html>
<head runat="server">
<title>College Info</title>
</head>
<body>
<form runat="server">
<div style="background-color:lightblue; padding:10px;">
<h1>My College</h1>
<a href="Home.aspx">Home</a> |
<a href="About.aspx">About</a>
</div>
<hr />
<asp:ContentPlaceHolder ID="MainContent" runat="server"></asp:ContentPlaceHolder>
<hr />
<footer>© 2025 My College</footer>
</form>
</body>
</html>

content pages: home
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<h2>Welcome to My College</h2>
<p>We offer B.Tech and M.Tech courses in CSE, ECE, and ME.</p>
</asp:Content>

content page: about
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<h2>About Our College</h2>
<p>Established in 2001, our college provides quality technical education.</p>
</asp:Content>
using System;
class Program {
    static void Main() {
        Console.Write("Enter number: ");
        int n = int.Parse(Console.ReadLine());
        int min = 9;
        while(n > 0) {
            int d = n % 10;
            if(d < min) min = d;
            n /= 10;
        }
        Console.WriteLine("Smallest digit: " + min);
    }
}
using System;
using System.Linq;
class Program {
    static void Main() {
        Console.Write("Enter string: ");
        string str = Console.ReadLine();
        var maxChar = str.GroupBy(c => c)
                         .OrderByDescending(g => g.Count())
                         .First().Key;
        Console.WriteLine("Max Occurring: " + maxChar);
    }
}
using System;
class Program {
    static void Main() {
        Console.Write("Enter number: ");
        int n = int.Parse(Console.ReadLine()), count = 0;
        while(n != 0) {
            int d = n % 10;
            if(d % 2 == 1) count++;
            n /= 10;
        }
        Console.WriteLine("Odd digits: " + count);
    }
}
using System;
class Program {
    static void Main() {
        Console.Write("Enter string: ");
        string str = Console.ReadLine();
        Console.Write("Enter start and length: ");
        int start = int.Parse(Console.ReadLine());
        int length = int.Parse(Console.ReadLine());
        string sub = str.Substring(start, length);
        Console.WriteLine("Substring: " + sub);
    }
}
using System;
using System.Text;
class Program {
    static void Main() {
        string str = "hello";
        Console.WriteLine(str.ToUpper());
        Console.WriteLine(str.Replace('l','x'));
        StringBuilder sb = new StringBuilder(str);
        sb.Append(" world");
        Console.WriteLine(sb.ToString());
        sb.Remove(0,2);
        Console.WriteLine(sb);
        sb.Insert(0, "hi ");
        Console.WriteLine(sb);
    }
}
using System;
class Program {
    static void Main() {
        Console.Write("Enter string: ");
        string str = Console.ReadLine();
        int count = str.Count(c => "aeiouAEIOU".Contains(c));
        Console.WriteLine("Vowels: " + count);
    }
}
using System;
class Program {
    static void Main() {
        Console.Write("Enter a number: ");
        int n = int.Parse(Console.ReadLine()), sum = 0;
        while(n > 0) {
            sum += n % 10;
            n /= 10;
        }
        Console.WriteLine("Sum: " + sum);
    }
}
using System;
class Program {
    static void Main() {
        Console.Write("Enter a number: ");
        int n = int.Parse(Console.ReadLine());
        int rev = 0;
        while(n > 0) {
            rev = rev * 10 + n % 10;
            n /= 10;
        }
        Console.WriteLine("Reversed: " + rev);
    }
}
using System;
using System.Linq;
class Program {
    static void Main() {
        Console.Write("Enter string: ");
        string str = Console.ReadLine();
        string rev = new string(str.Reverse().ToArray());
        Console.WriteLine(str == rev ? "Palindrome" : "Not palindrome");
    }
}
using System;
class Program {
    static void Main() {
        Console.Write("Enter terms: ");
        int n = int.Parse(Console.ReadLine());
        int a=0, b=1, c;
        for(int i = 0; i < n; i++) {
            Console.Write(a + " ");
            c = a + b;
            a = b;
            b = c;
        }
    }
}
using System;
class Program {
    static void Main() {
        Console.Write("Enter a number: ");
        int n = int.Parse(Console.ReadLine());
        bool isPrime = n > 1;
        for(int i = 2; i <= Math.Sqrt(n); i++) {
            if(n % i == 0) {
                isPrime = false; break;
            }
        }
        Console.WriteLine(isPrime ? "Prime" : "Not prime");
    }
}
Step 1: Create the ASP.NET Web Application

Open Visual Studio → Create New Project → ASP.NET Web Application (.NET Framework).

Name it: EmployeeManagementSystem.

Select Web Forms → Click Create.

Step 2: Create the Master Page

Add → New Item → Master Page → Name: Site1.Master

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="employee.Site1" %>

<!DOCTYPE html>
<html lang="en">
<head runat="server">
    <title>Employee Management System</title>
    <asp:ContentPlaceHolder ID="head" runat="server"></asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
        <!-- Header -->
        <div class="header">
            <h1>Employee Management System</h1>
            <nav>
                <a href="Default.aspx">Home</a> |
                <a href="AddEmployee.aspx">Add Employee</a> |
                <a href="ViewEmployee.aspx">View Employee</a>
            </nav>
        </div>

        <!-- Main Content -->
        <asp:ContentPlaceHolder ID="MainContent" runat="server"></asp:ContentPlaceHolder>

        <!-- Footer -->
        <div class="footer">
            <p>&copy; 2025 Employee Management System</p>
        </div>
    </form>
</body>
</html>

Step 3: Create the Home Page

Add → Web Form using Master Page → Name: Default.aspx → Select Site1.Master

<%@ Page Title="Home" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="employee.Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <h2>Welcome to the Home Page</h2>
    <p>Use the menu above to navigate through the Employee Management System.</p>
</asp:Content>

Step 4: Create Add Employee Page

Add → Web Form using Master Page → Name: AddEmployee.aspx → Select Site1.Master

AddEmployee.aspx
<%@ Page Title="Add Employee" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="AddEmployee.aspx.cs" Inherits="employee.AddEmployee" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <h2>Add Employee</h2>

    <asp:TextBox ID="empName" runat="server"></asp:TextBox><br /><br />
    <asp:TextBox ID="position" runat="server"></asp:TextBox><br /><br />
    <asp:TextBox ID="sal" runat="server"></asp:TextBox><br /><br />

    <asp:Button ID="btn" runat="server" Text="Add Employee" OnClick="btn_AddClick" /><br /><br />

    <asp:Label ID="lblMessage" runat="server" Text=""></asp:Label>
</asp:Content>

AddEmployee.aspx.cs
using System;
using System.Collections.Generic;

namespace employee
{
    public partial class AddEmployee : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                empName.Attributes["placeholder"] = "Enter employee name";
                position.Attributes["placeholder"] = "Enter employee position";
                sal.Attributes["placeholder"] = "Enter employee salary";
            }
        }

        protected void btn_AddClick(object sender, EventArgs e)
        {
            string name = empName.Text;
            string pos = position.Text;
            string salary = sal.Text;

            List<Employee> employees = Session["Employees"] as List<Employee> ?? new List<Employee>();
            employees.Add(new Employee { Name = name, Position = pos, Salary = salary });
            Session["Employees"] = employees;

            lblMessage.Text = "Employee added successfully!";

            empName.Text = position.Text = sal.Text = "";
        }
    }

    [Serializable]
    public class Employee
    {
        public string Name { get; set; }
        public string Position { get; set; }
        public string Salary { get; set; }
    }
}

Step 5: Create View Employee Page

Add → Web Form using Master Page → Name: ViewEmployee.aspx → Select Site1.Master

ViewEmployee.aspx
<%@ Page Title="View Employees" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="ViewEmployee.aspx.cs" Inherits="employee.ViewEmployee" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <h2>All Employees</h2>
    <asp:GridView ID="gv" runat="server" AutoGenerateColumns="true"></asp:GridView>
</asp:Content>

ViewEmployee.aspx.cs
using System;
using System.Collections.Generic;

namespace employee
{
    public partial class ViewEmployee : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                List<Employee> employees = Session["Employees"] as List<Employee> ?? new List<Employee>();
                gv.DataSource = employees;
                gv.DataBind();
            }
        }
    }
}
WebForm1.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="userreg.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>User Registration</title>
    <style>
        .error { color: red; }
        .form-field { margin-bottom: 10px; }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <h2>Registration Form</h2>

            <div class="form-field">
                Name: 
                <asp:TextBox ID="txtName" runat="server" AutoPostBack="true" OnTextChanged="txtName_TextChanged"></asp:TextBox>
                <asp:RequiredFieldValidator ID="rfvName" runat="server" 
                    ControlToValidate="txtName" ErrorMessage="Name is required" CssClass="error"></asp:RequiredFieldValidator>
            </div>

            <div class="form-field">
                Age:
                <asp:TextBox ID="txtAge" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="rfvAge" runat="server"
                    ControlToValidate="txtAge" ErrorMessage="Age is required" CssClass="error"></asp:RequiredFieldValidator>
                <asp:RangeValidator ID="rvAge" runat="server" 
                    ControlToValidate="txtAge" MinimumValue="20" MaximumValue="30" Type="Integer" 
                    ErrorMessage="Age must be between 20 and 30" CssClass="error"></asp:RangeValidator>
            </div>

            <div class="form-field">
                Email ID:
                <asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="rfvEmail" runat="server"
                    ControlToValidate="txtEmail" ErrorMessage="Email is required" CssClass="error"></asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="revEmail" runat="server"
                    ControlToValidate="txtEmail"
                    ErrorMessage="Invalid Email"
                    ValidationExpression="^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"
                    CssClass="error">
                </asp:RegularExpressionValidator>
            </div>

            <div class="form-field">
                User ID:
                <asp:TextBox ID="txtUserID" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="rfvUserID" runat="server"
                    ControlToValidate="txtUserID" ErrorMessage="UserID is required" CssClass="error"></asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="revUserID" runat="server"
                    ControlToValidate="txtUserID"
                    ErrorMessage="UserID must contain a capital letter and a digit, 7-20 chars"
                    ValidationExpression="^(?=.*[A-Z])(?=.*\d).{7,20}$"
                    CssClass="error">
                </asp:RegularExpressionValidator>
            </div>

            <div class="form-field">
                Password:
                <asp:TextBox ID="txtPassword" runat="server" TextMode="Password"></asp:TextBox>
                <asp:RequiredFieldValidator ID="rfvPassword" runat="server"
                    ControlToValidate="txtPassword" ErrorMessage="Password is required" CssClass="error"></asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="revPassword" runat="server"
                    ControlToValidate="txtPassword"
                    ErrorMessage="Password must be 7-20 chars"
                    ValidationExpression="^.{7,20}$"
                    CssClass="error">
                </asp:RegularExpressionValidator>
            </div>

            <div class="form-field">
                <asp:Button ID="btnSubmit" runat="server" Text="Register" OnClick="btnSubmit_Click" />
            </div>

            <asp:Label ID="lblMessage" runat="server" ForeColor="Green"></asp:Label>

        </div>
    </form>
</body>
</html>




WebForm1.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace userreg
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            UnobtrusiveValidationMode = UnobtrusiveValidationMode.None;
        }

        protected void txtName_TextChanged(object sender, EventArgs e)
        {

        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                lblMessage.Text = "Registration Successful!";
                // Optional: Save data to database here
            }
        }
    }
}




Steps:

1. Choose ASP.NET Web Application (.NET Framework)
2. Choose empty and Check the Web Forms
3. Right click on solution explorer and add a new item web forms and edit the codes and paste the above 2 codes
4. make sure to right click on webform1.aspx and click set as start page
5. click run
Form1.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            using (WebClient client = new WebClient())
            {
                string url = textBox1.Text;
                string filePath = @"C:\Users\Koyya\OneDrive\Desktop\example.txt";

                client.DownloadFile(url, filePath);

                MessageBox.Show("dome");


            }
        }
    }
}

========================



Steps

1. Create a new project using Windows Forms App (.NET Framework)
2.Add Controls to the Form using ToolBox

	TextBox → for entering URL (textBox1)

	Button → for DOWNLOAD (buttonDownload)

	Button → for UPLOAD (button1)

	Label → to show status (label1)


3. Double click on both the buttons and paste the above functions in those functions of respective buttons
Step - 1

=====================

Site1.Master

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="StudentApplication.Site1" %>

<!DOCTYPE html>
<html>
<head runat="server">
    <title>College Information</title>
    <link rel="stylesheet" href="style.css" />
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
        <!-- Header -->
        <header style="background-color:#f5f5f5; padding:20px; text-align:center;">
            <h1>CVR College of Engineering</h1>
        </header>

        <!-- Menu -->
        <asp:Menu ID="menu1" runat="server" Orientation="Horizontal">
            <Items>
                <asp:MenuItem NavigateUrl="~/Home.aspx" Text="HOME" Value="HOME" />
            </Items>
        </asp:Menu>

        <!-- College Image -->
        <div style="text-align:center; margin:20px;">
            <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/cur.jpg" Width="50%" />
        </div>

        <!-- Content Area -->
        <div class="content-area" style="margin:20px;">
            <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server" />
        </div>

        <!-- Footer -->
        <footer style="background-color:#eee; text-align:center; padding:15px; font-size:12px;">
            © 2025 Student Management System. All rights reserved
        </footer>
    </form>
</body>
</html>


==================

WebForm1.aspx

<%@ Page Title="Home" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="StudentApplication.WebForm1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <h2>Welcome to CVR College of Engineering</h2>
    <p>This student management system helps in managing student records efficiently.</p>
</asp:Content>

===================


Steps:

1. Select ASP.NET Web Application(.NET Framework) with C#
2. Name it StudentApplication
3. Click Create and select empty and tick WebForms checkbox
4. Click Create
5. Right click on solution explorer and click add -> new item -> web forms master page -> add
6. Paste the above Site1.Master code in it
7. Right click on solution explorer and click add -> new item -> web forms with master page -> add -> site1.master -> ok
8. paste the above WebForm1.aspx code in it
9. Right click on WebForm1.aspx in solution explorer and click set as start page
10. Run the code


=====================

Note: If you set another name to your project, change it in the first line of Inherits attribute
 using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsAppFinal
{
    public partial class Form1 : Form
    {
        WebClient client = new WebClient();

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string url = textBox1.Text.Trim();
                if (string.IsNullOrEmpty(url))
                {
                    label1.Text = "Please enter a download URL.";
                    return;
                }

                string savePath = "C:\\Users\\AKHILESH\\OneDrive\\Desktop\\download.txt";


                client.DownloadFile(url, savePath);
                label1.Text = "File downloaded to " + savePath;
            }
            catch (Exception ex)
            {
                label2.Text = "Error: " + ex.Message;
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                string url = textBox2.Text; // Example: https://httpbin.org/post
                string filePath = "C:\\Users\\AKHILESH\\OneDrive\\Desktop\\dummy.txt";

                client.UploadFile(url, "POST", filePath);
                MessageBox.Show("File uploaded successfully!");


                label2.Text = "Upload completed";
            }
            catch (Exception ex)
            {
                label2.Text = "Error: " + ex.Message;
            }
        }
    }

}
 
        https://raw.githubusercontent.com/vinta/awesome-python/master/README.md
https://httpbin.org/post
using System;

namespace practice
{
    public delegate int MathOperation(int x, int y);

    public class DelegateExample
    {
        public static int Add(int x, int y)
        {
            return x + y;
        }

        public static void Main()
        {
            MathOperation d = Add;
            int res = d(2, 3);
            Console.WriteLine("Result: "+res);
        }
    }
}
using System;

namespace practice
{
    interface IEmployee
    {
        void empdisplaydetails();
    }

    interface IManager : IEmployee
    {
        void Managerdetails();
    }

    class Departmentdetails : IManager
    {
        void IEmployee.empdisplaydetails()
        {
            Console.WriteLine("Employee Details");
        }

        void IManager.Managerdetails()
        {
            Console.WriteLine("Manager is working in sales department");
        }
    }

    class Program
    {
        public static void Main(string[] args)
        {
            Departmentdetails d = new Departmentdetails();

            IEmployee emp = d;
            emp.empdisplaydetails();

            IManager mg = d;
            mg.Managerdetails();
        }
    }
}
using System;
using System.Text.RegularExpressions;

class Program
{
    static void Main()
    {
        Console.Write("Enter an email: ");
        string email = Console.ReadLine();

        string pattern = @"^[^@\s]+@[^@\s]+\.[^@\s]+$";

        if (Regex.IsMatch(email, pattern))
            Console.WriteLine("Email is in proper format.");
        else
            Console.WriteLine("Email is NOT in proper format.");
    }
}
//Step 1: Create the Private Assembly (Class Library)

//Open Visual Studio → Create a new project → select Class Library (.NET Framework).

//Name it: MyMathLibrary.

//Replace the default class code with:

using System;

namespace MyMathLibrary
{
    public class MathOperations
    {
        public int Add(int a, int b)
        {
            return a + b;
        }

        public int Multiply(int a, int b)
        {
            return a * b;
        }
    }
}


//Build the project → This generates MyMathLibrary.dll in bin\Debug\net6.0\.

//Step 2: Create the Console Application

//Open Visual Studio → Create a new project → Console App.

//Name it: UseMyMathLibrary.

//Step 3: Add Reference via Dependencies

//In Solution Explorer, expand the console app project (UseMyMathLibrary).

//Right-click Dependencies → Add Project Reference -> Browse -> MyMathLibrary->bin->Debug->.dll

//Check MyMathLibrary → click OK


//Step 4: Use the Assembly in Your Console App
using System;
using MyMathLibrary;

class Program
{
    static void Main()
    {
        MathOperations math = new MathOperations();

        int sum = math.Add(10, 20);
        int product = math.Multiply(5, 4);

        Console.WriteLine("Sum: " + sum);
        Console.WriteLine("Product: " + product);
    }
}
using System;

class Program
{
    static void Main()
    {
        Console.Write("Enter a number: ");
        int num = Convert.ToInt32(Console.ReadLine());

        int smallest = 9;

        while (num > 0)
        {
            int digit = num % 10;
            if (digit < smallest)
                smallest = digit;
            num /= 10;
        }

        Console.WriteLine("Smallest digit: " + smallest);
    }
}
using System;

class Program
{
    static void Main()
    {
        Console.Write("Enter a string: ");
        string str = Console.ReadLine().ToLower();

        int[] freq = new int[256]; 

        foreach (char ch in str)
        {
            if (ch != ' ')
                freq[ch]++;
        }

        int max = 0;
        char maxChar = ' ';

        for (int i = 0; i < 256; i++)
        {
            if (freq[i] > max)
            {
                max = freq[i];
                maxChar = (char)i;
            }
        }

        Console.WriteLine("Maximum occurring character: " + maxChar);
        Console.WriteLine("Occurrences: " + max);
    }
}
//Site1.Master
 <style>
     body {
         font-family: Arial, sans-serif;
         margin: 0;
         padding: 0;
     }

     header {
         background-color: #003366;
         color: white;
         padding: 15px;
         text-align: center;
         font-size: 24px;
     }

     nav {
         background-color: #005599;
         overflow: hidden;
     }

     nav a {
         float: left;
         display: block;
         color: white;
         text-align: center;
         padding: 14px 20px;
         text-decoration: none;
     }

     nav a:hover {
         background-color: #003366;
     }

     footer {
         background-color: #003366;
         color: white;
         text-align: center;
         padding: 10px;
         position: fixed;
         bottom: 0;
         width: 100%;
     }

     .content {
         padding: 20px;
         margin-bottom: 60px; /* space for footer */
     }
 </style>

//inside form tag
 <header>
     Welcome to ABC College of Engineering
 </header>

 <nav>
     <a href="Home.aspx">Home</a>
     <a href="Aboutus.aspx">About</a>
     
     <a href="Contactus.aspx">Contact</a>
 </nav>

 <div class="content">
     <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
     </asp:ContentPlaceHolder>
 </div>

 <footer>
     &copy; 2025 ABC College | All Rights Reserved
 </footer>
//Aboutus.apsx
    <h2>About Our College</h2>
<p>Founded in 1990, ABC College of Engineering is one of the premier institutions offering quality education.</p>
<p>Our mission is to produce skilled engineers and leaders capable of addressing global challenges.</p>
//similarly Contactus.aspx
using System;

class Program
{
    static void Main()
    {
        Console.Write("Enter a string: ");
        string str = Console.ReadLine();

        Console.Write("Enter the starting index: ");
        int start = Convert.ToInt32(Console.ReadLine());

        Console.Write("Enter the length of substring: ");
        int length = Convert.ToInt32(Console.ReadLine());

        string sub = str.Substring(start, length);

        Console.WriteLine("Extracted Substring: " + sub);
    }
}
using System;
using System.Text; // Required for StringBuilder

class Program
{
    static void Main()
    {
        // --- String Class Methods ---
        Console.WriteLine("=== String Class Methods ===");
        string str = "Hello World";

        Console.WriteLine("Original String: " + str);
        Console.WriteLine("To Upper Case: " + str.ToUpper());
        Console.WriteLine("To Lower Case: " + str.ToLower());
        Console.WriteLine("Substring (0,5): " + str.Substring(0, 5));
        Console.WriteLine("Replaced 'World' with 'C#': " + str.Replace("World", "C#"));
        Console.WriteLine("Contains 'Hello'? " + str.Contains("Hello"));
        Console.WriteLine("Length: " + str.Length);

        // --- StringBuilder Class Methods ---
        Console.WriteLine("\n=== StringBuilder Class Methods ===");
        StringBuilder sb = new StringBuilder("Hello");

        sb.Append(" World");
        Console.WriteLine("After Append: " + sb);

        sb.Insert(5, " C#");
        Console.WriteLine("After Insert: " + sb);

        sb.Replace("World", "Developers");
        Console.WriteLine("After Replace: " + sb);

        sb.Remove(5, 3);
        Console.WriteLine("After Remove: " + sb);

        sb.Clear();
        sb.Append("New String");
        Console.WriteLine("After Clear and Append: " + sb);
    }
}
using System;

class Program
{
    static void Main()
    {
        Console.Write("Enter a string: ");
        string str = Console.ReadLine().ToLower();

        int count = 0;

        foreach (char ch in str)
        {
            if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u')
            {
                count++;
            }
        }

        Console.WriteLine("Number of vowels: " + count);
    }
}
class Program
{
    static void Main()
    {
        Console.WriteLine("Enter a Number: ");
        int num = Convert.ToInt32(Console.ReadLine());

        int sum = 0;

        while (num > 0)
        {
            int digit = num % 10;
            sum += digit;
            num /= 10;
        }

        Console.WriteLine("Sum of digits: " + sum);

    }
}
class Program
{
    static void Main()
    {
        Console.WriteLine("Enter a Number: ");
        int num = Convert.ToInt32(Console.ReadLine());

        int reversed = 0;

        while (num > 0)
        {
            int digit = num % 10;
            reversed = reversed * 10 + digit;
            num /= 10;
        }

        Console.WriteLine("Reversed Num: " + reversed);

    }
}
using System;
class SmallestDigit
{
    static void Main()
    {
        Console.Write("Enter a number: ");
        int num = Convert.ToInt32(Console.ReadLine());
        int smallest = 9;

        while (num > 0)
        {
            int digit = num % 10;
            if (digit < smallest)
                smallest = digit;
            num /= 10;
        }

        Console.WriteLine("Smallest digit: " + smallest);
    }
}
using System;
class MaxOccurringChar
{
    static void Main()
    {
        Console.Write("Enter a string: ");
        string str = Console.ReadLine();
        int[] freq = new int[256];

        foreach (char c in str)
            freq[c]++;

        int max = 0;
        char result = ' ';

        foreach (char c in str)
        {
            if (freq[c] > max)
            {
                max = freq[c];
                result = c;
            }
        }

        Console.WriteLine($"Maximum occurring character: {result}");
    }
}
class Program
{
    static void Main()
    {
        Console.WriteLine("Enter a String: ");
        string str = Console.ReadLine();

        string reversed = "";
        
        for(int i = str.Length - 1; i >= 0; i--)
        {
            reversed += str[i];
        }

        Boolean equal = true;

        for(int i = 0; i < str.Length; i++)
        {
            if (!(str[i] == reversed[i]))
            {
                equal = false; break;
            }
        }

        Console.WriteLine(equal ? "String is Palindrome" : "String is not a Palindrome");

    }
}
using System;
class CountOddDigits
{
    static void Main()
    {
        Console.Write("Enter a number: ");
        int num = Convert.ToInt32(Console.ReadLine());
        int count = 0;

        while (num > 0)
        {
            int digit = num % 10;
            if (digit % 2 != 0)
                count++;
            num /= 10;
        }

        Console.WriteLine("Count of odd digits: " + count);
    }
}
using System;
class Program {
    static void Main() {
        Console.Write("Enter string: ");
        string str = Console.ReadLine();
        Console.Write("Enter start and length: ");
        int start = int.Parse(Console.ReadLine());
        int length = int.Parse(Console.ReadLine());
        string sub = str.Substring(start, length);
        Console.WriteLine("Substring: " + sub);
    }
}
using System;
using System.Text;
class StringManipulation
{
    static void Main()
    {
        string s = "Hello";
        Console.WriteLine("Original String: " + s);
        s = s.ToUpper();
        Console.WriteLine("Uppercase: " + s);
        s = s.Replace("HELLO", "WORLD");
        Console.WriteLine("Replaced: " + s);

        // StringBuilder
        StringBuilder sb = new StringBuilder("Welcome");
        sb.Append(" to C#");
        Console.WriteLine("StringBuilder Append: " + sb);
        sb.Insert(0, "Hi! ");
        Console.WriteLine("After Insert: " + sb);
        sb.Replace("C#", "Programming");
        Console.WriteLine("After Replace: " + sb);
    }
}
using System;
class Program {
    static void Main() {
        Console.Write("Enter string: ");
        string str = Console.ReadLine();
        int count = str.Count(c => "aeiouAEIOU".Contains(c));
        Console.WriteLine("Vowels: " + count);
    }
}
using System;
class SumOfDigits
{
    static void Main()
    {
        Console.Write("Enter a number: ");
        int num = Convert.ToInt32(Console.ReadLine());
        int sum = 0;

        while (num > 0)
        {
            sum += num % 10;
            num /= 10;
        }

        Console.WriteLine("Sum of digits: " + sum);
    }
}
using System;
class ReverseNumber
{
    static void Main()
    {
        Console.Write("Enter a number: ");
        int num = Convert.ToInt32(Console.ReadLine());
        int rev = 0;

        while (num > 0)
        {
            rev = rev * 10 + num % 10;
            num = num / 10;
        }

        Console.WriteLine("Reversed Number: " + rev);
    }
}
using System;
using System.Linq;
class Program {
    static void Main() {
        Console.Write("Enter string: ");
        string str = Console.ReadLine();
        string rev = new string(str.Reverse().ToArray());
        Console.WriteLine(str == rev ? "Palindrome" : "Not palindrome");
    }
}

or 

using System;
class Palindrome
{
    static void Main()
    {
        Console.Write("Enter a string: ");
        string str = Console.ReadLine();
        string rev = "";

        for (int i = str.Length - 1; i >= 0; i--)
            rev += str[i];

        if (str == rev)
            Console.WriteLine("Palindrome");
        else
            Console.WriteLine("Not Palindrome");
    }
}

class Program
{
    static void Main()
    {
        Console.WriteLine("Enter a number: ");
        int N = Convert.ToInt32(Console.ReadLine());

        int first = 0;
        int second = 1;

        Console.WriteLine("Fibonacci Series");

        for(int i = 1; i <= N; i++)
        {
            Console.Write(first + " ");
            int next = first + second;
            first = second;
            second = next;
        }

    }
}
using System;
class Fibonacci
{
    static void Main()
    {
        Console.Write("Enter the number of terms: ");
        int n = Convert.ToInt32(Console.ReadLine());
        int a = 0, b = 1, c;

        Console.Write("Fibonacci Series: ");
        for (int i = 1; i <= n; i++)
        {
            Console.Write(a + " ");
            c = a + b;
            a = b;
            b = c;
        }
    }
}
using System;
class Program {
    static void Main() {
        Console.Write("Enter a number: ");
        int n = int.Parse(Console.ReadLine());
        bool isPrime = n > 1;
        for(int i = 2; i <= Math.Sqrt(n); i++) {
            if(n % i == 0) {
                isPrime = false; break;
            }
        }
        Console.WriteLine(isPrime ? "Prime" : "Not prime");
    }
}
class Program
{
    static void Main()
    {
        Console.WriteLine("Enter a number: ");
        int num = Convert.ToInt32(Console.ReadLine());
        if (IsPrime(num))
        {
            Console.WriteLine("Prime Number");
        }
        else
        {
            Console.WriteLine("Not a Prime Number");
        }
    }

    static Boolean IsPrime(int num)
    {
        if (num == 1 || num == 0) return false;
        int c = 0;
        for(int i = 1; i <= num; i++)
        {
            if(num%i == 0)
            {
                c++;
            }
        }

        return c == 2;
    }
}
using System;

// Base class
class Employee
{
    public string Name { get; set; }
    public int EmployeeID { get; set; }
    public double Salary { get; set; }

    public Employee(string name, int id)
    {
        Name = name;
        EmployeeID = id;
    }

    // Virtual method to be overridden in derived classes
    public virtual void CalculateSalary()
    {
        Salary = 0;
    }

    public void Display()
    {
        Console.WriteLine("Employee Name: " + Name);
        Console.WriteLine("Employee ID: " + EmployeeID);
        Console.WriteLine("Salary: " + Salary);
        Console.WriteLine("-----------------------------");
    }
}

// Derived class: FullTimeEmployee
class FullTimeEmployee : Employee
{
    public double BasicSalary { get; set; }
    public int NumberOfDays { get; set; }
    public double HRA { get; set; }
    public double DA { get; set; }

    public FullTimeEmployee(string name, int id, double basic, int days, double hra, double da)
        : base(name, id)
    {
        BasicSalary = basic;
        NumberOfDays = days;
        HRA = hra;
        DA = da;
    }

    public override void CalculateSalary()
    {
        Salary = (BasicSalary * NumberOfDays) + HRA + DA;
    }
}

// Derived class: PartTimeEmployee
class PartTimeEmployee : Employee
{
    public double DailyWages { get; set; }
    public int NumberOfDays { get; set; }

    public PartTimeEmployee(string name, int id, double wages, int days)
        : base(name, id)
    {
        DailyWages = wages;
        NumberOfDays = days;
    }

    public override void CalculateSalary()
    {
        Salary = DailyWages * NumberOfDays;
    }
}

// Main Program
class Program
{
    static void Main()
    {
        // Create Full-Time Employee
        FullTimeEmployee fte = new FullTimeEmployee("Alice", 101, 1000, 22, 500, 300);
        fte.CalculateSalary();
        fte.Display();

        // Create Part-Time Employee
        PartTimeEmployee pte = new PartTimeEmployee("Bob", 102, 500, 15);
        pte.CalculateSalary();
        pte.Display();

        Console.ReadLine();
    }
}
using System;

// Step 1: Base interface
interface IShape
{
    void Draw();
}

// Step 2: Derived interface inherits from IShape
interface IColorShape : IShape
{
    void FillColor();
}

// Step 3: Implement the derived interface explicitly
class Rectangle : IColorShape
{
    // Explicit implementation of Draw() from IShape
    void IShape.Draw()
    {
        Console.WriteLine("Drawing a Rectangle");
    }

    // Explicit implementation of FillColor() from IColorShape
    void IColorShape.FillColor()
    {
        Console.WriteLine("Filling Rectangle with Blue color");
    }
}

class Program
{
    static void Main()
    {
        // Create object of Rectangle
        Rectangle rect = new Rectangle();

        // To access explicit interface methods, we need to cast to interface
        IShape shape = rect;
        shape.Draw();  // Calls IShape.Draw()

        IColorShape colorShape = rect;
        colorShape.FillColor();  // Calls IColorShape.FillColor()

        Console.ReadLine();
    }
}

 public delegate void OperationOnDelegate(int x,int y);
 internal class Program
 {
     public static void Add(int x,int y)
     {
         Console.WriteLine($"Add:{x + y}");

     }

     public static void Sub(int x, int y)
     {
         Console.WriteLine($"Sub:{x - y}");


     }

     public static void Mul(int x, int y)
     {
         Console.WriteLine($"Sub:{x * y}");
     }




     static void Main(string[] args)
     {
         OperationOnDelegate op;
         op = Add;
         op(10, 20);
         op = Sub;
         op(10, 20);
         op = Mul;
         op(10, 20);
         op = Add;
         op += Sub;
         op += Mul;
         op(20, 10);
     }
 }
star

Sun Oct 12 2025 17:53:16 GMT+0000 (Coordinated Universal Time)

@vplab2025 #c#

star

Sun Oct 12 2025 17:37:00 GMT+0000 (Coordinated Universal Time)

@final

star

Sun Oct 12 2025 17:34:48 GMT+0000 (Coordinated Universal Time)

@final

star

Sun Oct 12 2025 17:22:45 GMT+0000 (Coordinated Universal Time)

@final

star

Sun Oct 12 2025 17:19:03 GMT+0000 (Coordinated Universal Time)

@robo

star

Sun Oct 12 2025 17:10:31 GMT+0000 (Coordinated Universal Time)

@final

star

Sun Oct 12 2025 17:10:07 GMT+0000 (Coordinated Universal Time)

@final

star

Sun Oct 12 2025 17:09:46 GMT+0000 (Coordinated Universal Time)

@final

star

Sun Oct 12 2025 17:09:25 GMT+0000 (Coordinated Universal Time)

@final

star

Sun Oct 12 2025 17:09:03 GMT+0000 (Coordinated Universal Time)

@final

star

Sun Oct 12 2025 17:08:40 GMT+0000 (Coordinated Universal Time)

@final

star

Sun Oct 12 2025 17:08:20 GMT+0000 (Coordinated Universal Time)

@final

star

Sun Oct 12 2025 17:07:54 GMT+0000 (Coordinated Universal Time)

@final

star

Sun Oct 12 2025 17:07:32 GMT+0000 (Coordinated Universal Time)

@final

star

Sun Oct 12 2025 17:06:35 GMT+0000 (Coordinated Universal Time)

@final

star

Sun Oct 12 2025 17:06:05 GMT+0000 (Coordinated Universal Time)

@final

star

Sun Oct 12 2025 17:02:11 GMT+0000 (Coordinated Universal Time)

@vplab2025 #c#

star

Sun Oct 12 2025 17:01:54 GMT+0000 (Coordinated Universal Time)

@vplab2025 #c#

star

Sun Oct 12 2025 17:01:25 GMT+0000 (Coordinated Universal Time)

@vplab2025 #c#

star

Sun Oct 12 2025 17:00:58 GMT+0000 (Coordinated Universal Time)

@vplab2025 #c#

star

Sun Oct 12 2025 16:31:03 GMT+0000 (Coordinated Universal Time)

@rcb

star

Sun Oct 12 2025 14:55:28 GMT+0000 (Coordinated Universal Time)

@vplab2025 #c#

star

Sun Oct 12 2025 14:47:58 GMT+0000 (Coordinated Universal Time)

@vplab2025 #c#

star

Sun Oct 12 2025 14:41:38 GMT+0000 (Coordinated Universal Time)

@vplab2025 #c#

star

Sun Oct 12 2025 14:37:27 GMT+0000 (Coordinated Universal Time)

@vplab2025 #c#

star

Sun Oct 12 2025 13:47:45 GMT+0000 (Coordinated Universal Time)

@vplab2025 #c#

star

Sun Oct 12 2025 13:46:39 GMT+0000 (Coordinated Universal Time)

@vplab2025 #c#

star

Sun Oct 12 2025 13:45:23 GMT+0000 (Coordinated Universal Time)

@rcb

star

Sun Oct 12 2025 13:42:21 GMT+0000 (Coordinated Universal Time)

@vplab2025 #c#

star

Sun Oct 12 2025 13:37:27 GMT+0000 (Coordinated Universal Time)

@vplab2025 #c#

star

Sun Oct 12 2025 13:34:25 GMT+0000 (Coordinated Universal Time)

@vplab2025 #c#

star

Sun Oct 12 2025 13:33:31 GMT+0000 (Coordinated Universal Time)

@vplab2025 #c#

star

Sun Oct 12 2025 13:32:35 GMT+0000 (Coordinated Universal Time)

@vplab2025 #c#

star

Sun Oct 12 2025 13:29:56 GMT+0000 (Coordinated Universal Time)

@robo

star

Sun Oct 12 2025 13:29:31 GMT+0000 (Coordinated Universal Time)

@robo

star

Sun Oct 12 2025 13:28:49 GMT+0000 (Coordinated Universal Time)

@vplab2025 #c#

star

Sun Oct 12 2025 13:28:05 GMT+0000 (Coordinated Universal Time)

@robo

star

Sun Oct 12 2025 13:27:37 GMT+0000 (Coordinated Universal Time)

@robo

star

Sun Oct 12 2025 13:27:03 GMT+0000 (Coordinated Universal Time)

@robo

star

Sun Oct 12 2025 13:26:36 GMT+0000 (Coordinated Universal Time)

@robo

star

Sun Oct 12 2025 13:26:02 GMT+0000 (Coordinated Universal Time)

@robo

star

Sun Oct 12 2025 13:25:25 GMT+0000 (Coordinated Universal Time)

@robo

star

Sun Oct 12 2025 13:24:16 GMT+0000 (Coordinated Universal Time)

@robo

star

Sun Oct 12 2025 13:24:14 GMT+0000 (Coordinated Universal Time)

@vplab2025 #c#

star

Sun Oct 12 2025 13:23:26 GMT+0000 (Coordinated Universal Time)

@robo

star

Sun Oct 12 2025 13:22:49 GMT+0000 (Coordinated Universal Time)

@robo

star

Sun Oct 12 2025 13:20:15 GMT+0000 (Coordinated Universal Time)

@vplab2025 #c#

star

Sun Oct 12 2025 12:14:19 GMT+0000 (Coordinated Universal Time)

@rcb

star

Sun Oct 12 2025 09:46:23 GMT+0000 (Coordinated Universal Time)

@rcb

star

Sun Oct 12 2025 08:47:52 GMT+0000 (Coordinated Universal Time)

@rcb

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension