Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #practical 1
- using System;
- namespace ConsoleApplication1
- {
- class Ones
- {
- static void Main(string[] args)
- {
- Console.Write("Enter a Number : ");
- string a = Console.ReadLine();
- int len = a.Length;
- int n = Convert.ToInt32(a);
- int count = 0;
- int m = 0;
- for (int i = 0; i < len; i++)
- {
- m = n % 10;
- n = n / 10;
- if (m == 1)
- {
- count = count + 1;
- }
- }
- Console.WriteLine("Number of 1's: " + count);
- }
- }
- }
- #parctical 3
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1
- {
- class Userpass
- {
- public static void Main(string[] args)
- {
- String user = "dotnet";
- String pass = "technologies";
- Console.Write("Enter Username: ");
- String userin = Console.ReadLine();
- Console.Write("Enter Password: ");
- String passin = Console.ReadLine();
- if (userin == user && passin == pass)
- {
- Console.WriteLine("Congratulation Access Granted");
- }
- else
- {
- Console.WriteLine("Username or Password is Incorrect");
- }
- }
- }
- }
- #practical 5
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication3
- {
- class StringMem
- {
- static void Main(string[] args)
- {
- String s1 = "DotNet Technologies";
- Console.Write("Enter the string to check : ");
- String s2 = Console.ReadLine();
- Console.WriteLine(s1.Contains(s2));
- Console.Write("\n\nEnter the string to insert : ");
- String s3 = Console.ReadLine();
- Console.Write("Enter the Loaction of Insertion of String : ");
- int loc1 = Int32.Parse(Console.ReadLine());
- Console.WriteLine(s1.Insert(loc1-1,s3));
- Console.Write("\n\n Enter the StartIndex of Removal of String : ");
- int loc2 = Int32.Parse(Console.ReadLine());
- Console.Write("Enter the Number of Characters to Remove : ");
- int num = Int32.Parse(Console.ReadLine());
- Console.WriteLine(s1.Remove(loc2 - 1, num));
- Console.Write("\n\nEnter the existing string : ");
- String s4 = Console.ReadLine();
- Console.Write("Enter the string to replace: ");
- String s5 = Console.ReadLine();
- Console.WriteLine(s1.Replace(s4, s5));
- }
- }
- }
- #practical 8
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace WindowsFormsApplication1
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private void user_Click(object sender, EventArgs e)
- {
- }
- private void usertext_TextChanged(object sender, EventArgs e)
- {
- }
- private void Passtext_TextChanged(object sender, EventArgs e)
- {
- }
- private void reset_Click(object sender, EventArgs e)
- {
- usertext.Clear();
- Passtext.Clear();
- }
- private void Submit_Click(object sender, EventArgs e)
- {
- string user = usertext.Text;
- string pass = Passtext.Text;
- if (user.Equals("") && pass.Equals(""))
- {
- MessageBox.Show("Fields Cannot be left blank");
- }
- else if (user.Equals("dotnet") && pass.Equals("technologies"))
- {
- MessageBox.Show("Access Granted");
- this.Close();
- }
- else
- {
- MessageBox.Show("Username or Password is Incorrect");
- usertext.Clear();
- Passtext.Clear();
- }
- }
- private void Loglab_Click(object sender, EventArgs e)
- {
- }
- }
- }
- #practical 9
- **Form 1
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace WindowsFormsApplication2
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void CalDOB_ValueChanged(object sender, EventArgs e)
- {
- }
- private void chkbtn_Click(object sender, EventArgs e)
- {
- int yy = int.Parse(yrtext.Text);
- int mm = int.Parse(mnthtext.Text);
- int dd = int.Parse(datetext.Text);
- DateTime d1=DateTime.Now ;
- DateTime d2 = new DateTime(yy,mm,dd);
- TimeSpan difference = d1.Subtract(d2);
- double dif = (difference.TotalDays/365.25);
- if (dif >= 18)
- {
- Form2 f2 = new Form2();
- MessageBox.Show("You are eligible for Voting");
- f2.Visible = true;
- }
- else
- {
- MessageBox.Show("Sorry,You can't vote");
- }
- }
- private void label1_Click(object sender, EventArgs e)
- {
- }
- private void reset_Click(object sender, EventArgs e)
- {
- nametext.Clear();
- addtext.Clear();
- datetext.ClearUndo();
- mnthtext.ClearUndo();
- yrtext.ClearUndo();
- }
- private void s_Click(object sender, EventArgs e)
- {
- if (nametext.Text == "" || addtext.Text == "" || datetext.Text=="DD" || mnthtext.Text=="MM" || yrtext.Text=="YYYY")
- {
- MessageBox.Show("Fields cannot be left blank");
- }
- else
- {
- MessageBox.Show("Thanks for Voting");
- this.Close();
- }
- }
- }
- }
- **Form 2
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace WindowsFormsApplication2
- {
- public partial class Form2 : Form
- {
- public Form2()
- {
- InitializeComponent();
- }
- private void Form2_Load(object sender, EventArgs e)
- {
- }
- private void INC_CheckedChanged(object sender, EventArgs e)
- {
- }
- private void AAP_CheckedChanged(object sender, EventArgs e)
- {
- }
- private void BJP_CheckedChanged(object sender, EventArgs e)
- {
- }
- private void subbtn_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void Votelbl_Click(object sender, EventArgs e)
- {
- }
- }
- }
Add Comment
Please, Sign In to add comment