Upcoming SlideShare
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

# Saving this for later?

### Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Standard text messaging rates apply

# C# labprograms

1,729
views

Published on

1 Like
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total Views
1,729
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
258
0
Likes
1
Embeds 0
No embeds

No notes for slide

### Transcript

• 1. .Net Laboratory Subject Code: MCA655 CIE Marks : 50 Hours/Week : 04 No of Credits: 1.5 Total Hours : 42 1.Write a Program in C# to Check whether a number is Palindrome or not. using System; class Palindrome { public static void Main( ) { //Declaring the variables int num; int initial_num; int digit; int reverse_number = 0; //prompt the user for a number Console.WriteLine("*******************"); Console.WriteLine("Provide a number"); Console.WriteLine("*******************"); Console.WriteLine("rn"); //read in the users input initial_num = int.Parse(Console.ReadLine()); num = initial_num; do { //set digit to the users number mod 10 digit = initial_num % 10; //reverse the number by multiplying it by 10 then //adding digit to it reverse_number = reverse_number * 10 + digit; initial_num /= 10; } while (initial_num != 0); //print out the number reversed Console.WriteLine("************************"); Console.WriteLine("The reverse of the numer is: {0}", reverse_number); Console.WriteLine("************************"); Console.WriteLine("rn"); //now check to see if the number is a palidrome if (num == reverse_number) { //since the number entered = the number reversed it is a palidrome Console.WriteLine("*******************************"); Console.WriteLine("This number is a palindrome!"); Console.WriteLine("*******************************"); Console.WriteLine("rn"); } else
• 2. { //number isnt a palidrome Console.WriteLine("*******************************"); Console.WriteLine("This number is not a palindrome"); Console.WriteLine("*******************************"); } } 2.Write a Program in C# to demonstrate Command line arguments Processing. using System; class CmdArgs{ public static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine("No arguments submitted"); Console.ReadLine(); return; } // processing a single argument Console.WriteLine("Squared Argument" + Environment.NewLine); // create variables to hold arguments Int32 orginalValue = 0; Int32 squaredValue = 0; try { orginalValue = int.Parse(args[0].ToString()); //first argument only squaredValue = orginalValue * orginalValue; Console.WriteLine(Environment.NewLine + Convert.ToString(orginalValue) + " Squared = " + Convert.ToString(squaredValue) + Environment.NewLine); Console.ReadLine(); return; } catch { // display indication of invalid input from command line Console.WriteLine(Environment.NewLine + "Invalid Input" + Environment.NewLine); Console.ReadLine(); return; } } }
• 3. using System; class cmd2{ static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine("No arguments submitted"); Console.ReadLine(); return; } Console.WriteLine("Add All" + Environment.NewLine); // create variables to hold arguments int RunningTotal = 0; // populate the variables from the arguments for (int i = 0; i < args.Length; i++) { try { RunningTotal = RunningTotal + Convert.ToInt32(args[i].ToString()); } catch { // Display error if input is missing or invalid Console.WriteLine(Environment.NewLine + "Invalid Input" + Environment.NewLine); Console.ReadLine(); return; } } Console.WriteLine(Environment.NewLine + "All numbers added = " + RunningTotal.ToString() + Environment.NewLine); Console.ReadLine(); return; } }
• 4. 3.Write a Program in C# to find the roots of Quadratic Equation. using System; class Quad { public static void Main() { int A, B, C; double disc, deno, x1, x2; Console.WriteLine("ENTER THE VALUES OF A,B,C..."); A=int.Parse(Console.ReadLine()); B=int.Parse(Console.ReadLine()); C=int.Parse(Console.ReadLine()); disc = (B * B) - (4 * A * C); deno = 2 * A; if(disc > 0) { Console.WriteLine("THE ROOTS ARE REAL ROOTS"); x1 = (-B/deno) + (Math.Sqrt(disc) / deno); x2 = (-B/deno) - (Math.Sqrt(disc) / deno); Console.WriteLine("THE ROOTS ARE...: {0} and {1}", x1, x2); } else if(disc == 0) { Console.WriteLine("THE ROOTS ARE REPEATED ROOTS"); x1 = -B/deno; Console.WriteLine("THE ROOT IS...: {0}", x1); } else { Console.WriteLine("THE ROOTS ARE IMAGINARY ROOTSn"); x1 = -B/deno; x2 = ((Math.Sqrt((4*A*C)-(B*B))) / deno); Console.WriteLine("THE ROOT ONE...: {0}+i{1}", x1, x2); Console.WriteLine("THE ROOTS ARE...: {0}-i{1}", x1, x2); } } }
• 5. 4.Write a Program in C# to demonstrate boxing and unBoxing. class TestUnboxing { static void Main() { int i = 123; object o = i; // implicit boxing try { //int j = (short)o; // attempt to unbox int j = (int)o; // attempt to unbox System.Console.WriteLine("Unboxing OK."); } catch (System.InvalidCastException e) { System.Console.WriteLine("{0} Error: Incorrect unboxing.", e.Message); } } }
• 6. 5.Write a Program in C# to implement Stack operations. namespace Stack { using System; public class Stack { private Node first = null; private int count = 0; /******************************************************************************* *********************************** Property Procedures do not accept any parameters. Note the diff in the function definition (no parenthesis) ******************************************************************************** ***********************************/ public bool Empty { /******************************************* Property Get Procedure ********************************************/ get { return (first == null); } } public int Count { /******************************************* Property Get Procedure ********************************************/ get { return count; } } public object Pop() { if (first == null) { throw new InvalidOperationException ("Cant pop from an empty stack"); } else { object temp = first.Value; first = first.Next; count--; return temp; } } public void Push(object o) { first = new Node(o, first);
• 7. count++; } class Node { public Node Next; public object Value; public Node(object value) : this(value, null) {} public Node(object value, Node next) { Next = next; Value = value; } } } class StackTest { static void Main() { Stack s = new Stack(); if (s.Empty) Console.WriteLine("Stack is Empty"); else Console.WriteLine("Stack is not Empty"); for (int i = 0; i < 5; i++) s.Push(i); Console.WriteLine("Items in Stack {0}", s.Count); for (int i = 0; i < 5; i++) Console.WriteLine("Popped Item is {0} and the count is {1}", s.Pop(), s.Count); s = null; } } }
• 8. using System; using System.Collections; using System.Windows.Forms; using System.Drawing; class StackDemo : Form { static Stack simpleStack; Button btnPush,btnPeek,btnPop; TextBox txtItem; Label lblItem,lblStack; ListBox lstStackUI; public StackDemo() { simpleStack = new Stack(32); lblItem = new Label(); lblItem.Text = "Item To Add"; lblItem.Location = new Point(16,16); lblItem.AutoSize = true; txtItem = new TextBox(); txtItem.Location = new Point(lblItem.Right + 8 ,lblItem.Top); txtItem.Size = new Size(256,27); btnPush = new Button(); btnPush.Size = btnPush.Size; btnPush.Location = new Point(txtItem.Right + 8,lblItem.Top); btnPush.Text = "Push"; btnPush.Click += new EventHandler(btnPush_Click); btnPeek = new Button(); btnPeek.Size = btnPush.Size; btnPeek.Location = new Point(btnPush.Right + 8,lblItem.Top); btnPeek.Text = "Peek"; btnPeek.Click += new EventHandler(btnPeek_Click); btnPop = new Button(); btnPop.Size = btnPush.Size; btnPop.Location = new Point(btnPeek.Right + 8,lblItem.Top); btnPop.Text = "Pop"; btnPop.Click += new EventHandler(btnPop_Click); lblStack = new Label(); lblStack.Location = new Point(lblItem.Left,lblItem.Bottom + 32); lblStack.Text = "Visual Stack"; lstStackUI = new ListBox(); lstStackUI.Location = new Point(lblItem.Left,lblStack.Bottom + 16); lstStackUI.Size = new Size(512,256); this.Text = "Stack Demo"; this.Controls.AddRange( new Control[] { lblItem,txtItem, btnPush,btnPeek,btnPop, lblStack,lstStackUI }); }
• 9. //Push element to the stack void btnPush_Click(object sender,EventArgs e) { if(txtItem.Text.Trim() != String.Empty) { simpleStack.Push(txtItem.Text.Trim()); lstStackUI.Items.Insert(0,"Pushed : " + txtItem.Text.Trim() + " At " + DateTime.Now.ToString()); } else { MessageBox.Show("Empty Value Cannot be Added","StackDemo", MessageBoxButtons.OK,MessageBoxIcon.Information); } } //How to get the top element of the Stack? void btnPeek_Click(object sender,EventArgs e) { try { MessageBox.Show("Peek Element: " + simpleStack.Peek().ToString()); } catch(Exception ex) { MessageBox.Show("Error: " + ex.Message,"StackDemo", MessageBoxButtons.OK,MessageBoxIcon.Error); } } //Method to show how to pop element from the Stack. void btnPop_Click(object sender,EventArgs e) { try { MessageBox.Show("Popped Element: " + simpleStack.Pop().ToString()); lstStackUI.Items.RemoveAt(0); } catch(Exception ex) { MessageBox.Show("Error: " + ex.Message,"StackDemo", MessageBoxButtons.OK,MessageBoxIcon.Error); } } static void Main() { Application.Run(new StackDemo()); } }
• 12. { Square s1=new Square(10); Square s2=new Square(20); Square s3=s1+s2; // This will call operator + (Square,Square) Console.WriteLine(s3); Console.WriteLine(s3+15); // This will call operator + (Square,int) and then ToString() Console.WriteLine(s3+1.5);// This will call operator + (Square,double) and then ToString() s3=10; // This will call operator Square(int) Console.WriteLine(s3); Square s4=10; Console.WriteLine(s1==s4); //Calls == operator Console.WriteLine(s1!=s4); //Calls != operator Console.WriteLine(s1>s2); //Calls > operator Console.WriteLine(s1<=s4); //Calls <= operator } }
• 13. 7.Write a Program in C# to find the second largest element in a single dimensional array. using System; class Biggest { int[] a={1,2,3,4}; public void ReadElement() { Console.WriteLine("n Enter the elements:"); for(int i=0;i<a.Length;i++) { a[i]=int.Parse(Console.ReadLine()); } } public void PrintElement() { Console.WriteLine("n The elements are:"); for(int i=0;i<a.Length;i++) { Console.WriteLine(a[i]); } } public void BigElement() { int big, sec; big=sec=a[0]; for(int i=1;i<a.Length;i++) { if(big < a[i]) { sec = big; big=a[i]; } } Console.WriteLine("first biggest {0} and second biggest {1}",big,sec); } } class Big { public static void Main() { Biggest MM=new Biggest(); MM.ReadElement(); MM.PrintElement(); MM.BigElement(); } }
• 14. 8.Write a Program in C# to multiply to matrices using Rectangular arrays. using System; class MatrixMultiplication { int[,] a; int[,] b; int[,] c; public void ReadMatrix() { Console.WriteLine("n Size of Matrix 1:"); Console.Write("n Enter the number of rows in Matrix 1 :"); int m=int.Parse(Console.ReadLine()); Console.Write("n Enter the number of columns in Matrix 1 :"); int n=int.Parse(Console.ReadLine()); a=new int[m,n]; Console.WriteLine("n Enter the elements of Matrix 1:"); for(int i=0;i<a.GetLength(0);i++) { for(int j=0;j<a.GetLength(1);j++) { a[i,j]=int.Parse(Console.ReadLine()); } } Console.WriteLine("n Size of Matrix 2 :"); Console.Write("n Enter the number of rows in Matrix 2 :"); m=int.Parse(Console.ReadLine()); Console.Write("n Enter the number of columns in Matrix 2 :"); n=int.Parse(Console.ReadLine()); b=new int[m,n]; Console.WriteLine("n Enter the elements of Matrix 2:"); for(int i=0;i<b.GetLength(0);i++) { for(int j=0;j<b.GetLength(1);j++) { b[i,j]=int.Parse(Console.ReadLine()); } } } public void PrintMatrix() { Console.WriteLine("n Matrix 1:"); for(int i=0;i<a.GetLength(0);i++) { for(int j=0;j<a.GetLength(1);j++) { Console.Write("t"+a[i,j]); } Console.WriteLine(); } Console.WriteLine("n Matrix 2:"); for(int i=0;i<b.GetLength(0);i++) {
• 15. for(int j=0;j<b.GetLength(1);j++) { Console.Write("t"+b[i,j]); } Console.WriteLine(); } Console.WriteLine("n Resultant Matrix after multiplying Matrix 1 & Matrix 2:"); for(int i=0;i<c.GetLength(0);i++) { for(int j=0;j<c.GetLength(1);j++) { Console.Write("t"+c[i,j]); } Console.WriteLine(); } } public void MultiplyMatrix() { if(a.GetLength(1)==b.GetLength(0)) { c=new int[a.GetLength(0),b.GetLength(1)]; for(int i=0;i<c.GetLength(0);i++) { for(int j=0;j<c.GetLength(1);j++) { c[i,j]=0; for(int k=0;k<a.GetLength(1);k++) // OR k<b.GetLength(0) c[i,j]=c[i,j]+a[i,k]*b[k,j]; } } } else { Console.WriteLine("n Number of columns in Matrix1 is not equal to Number of rows in Matrix2."); Console.WriteLine("n Therefore Multiplication of Matrix1 with Matrix2 is not possible"); Environment.Exit(-1); } } } class Matrices { public static void Main() { MatrixMultiplication MM=new MatrixMultiplication(); MM.ReadMatrix(); MM.MultiplyMatrix(); MM.PrintMatrix(); } }
• 16. 9. Find the sum of all the elements present in a jagged array of 3 inner arrays. using System; class JagArray { public static void Main() { int [][] myJagArray = new int[3][]; for(int i=0; i<myJagArray.Length;i++) { myJagArray[i] = new int[i+3]; } for(int i=0; i<3;i++) { Console.WriteLine("Enter {1} Elements of row {0}",i,myJagArray[i].Length); for(int j=0; j<myJagArray[i].Length;j++) { myJagArray[i][j]=int.Parse(Console.ReadLine()); } Console.WriteLine(); } int sum=0; for(int i=0; i<3;i++) { for(int j=0; j<myJagArray[i].Length;j++) { sum += myJagArray[i][j]; } } Console.WriteLine("The sum of Jagged Array is {0}", sum); } } 10.Write a program to reverse a given string using C#. using System; class RevStr { public static string Reverse(string str) { int len = str.Length; char[] arr = new char[len]; for (int i = 0; i < len; i++) { arr[i] = str[len - 1 - i]; } return new string(arr); }
• 17. public static void Main() { string str; string revstr; str=Console.ReadLine(); revstr=Reverse(str); Console.WriteLine(revstr); } } 11. Using Try, Catch and Finally blocks write a program in C# to demonstrate error handling. using System; class TryCatch{ public static void Main() { int a, b = 0 ; Console.WriteLine( "My program starts" ) ; try { a = 10 / b; } catch ( InvalidOperationException e ) { Console.WriteLine ( e ) ; } catch ( DivideByZeroException e) { Console.WriteLine ( e ) ; } finally { Console.WriteLine ( "finally" ) ; } Console.WriteLine ( "Remaining program" ) ; } } using System; class TryCatch { public static void Main() { int a, b = 0 ; Console.WriteLine( "My program starts" ) try { a = 10 / b; } finally
• 18. { Console.WriteLine ( "finally" ) ; } Console.WriteLine ( "Remaining program" ) ; } } 12. Design a simple calculator using Switch Statement in C#. using System; using System.Windows.Forms; using System.Drawing; public class win:Form { Button[] b = new Button[10]; Button bDot,bPlus,bSub,bMul,bDiv,bEqu,bClr; Panel panCalc; TextBox txtCalc; Double dblAcc; Double dblSec; bool blnClear,blnFrstOpen; String strOper; public win() { try { this.Text="Calculator"; panCalc=new Panel(); txtCalc = new TextBox(); txtCalc.Location = new Point(10,10); txtCalc.Size=new Size(150,10); txtCalc.ReadOnly=true; txtCalc.RightToLeft=RightToLeft.Yes; panCalc.Size=new Size(200,200); panCalc.BackColor=Color.Aqua; panCalc.Controls.Add(txtCalc); addButtons(panCalc); this.Size=new Size(200,225); this.Controls.Add(panCalc); dblAcc=0; dblSec=0; blnFrstOpen=true; blnClear=false; strOper=new String('=',1); } catch (Exception e) { Console.WriteLine("error ...... " + e.StackTrace); } } private void addButtons(Panel p) {
• 19. for (int i=0;i<=9;i++) { b[i]=new Button(); b[i].Text=Convert.ToString(i); b[i].Size=new Size(25,25); b[i].BackColor=Color.White; b[i].Click+=new EventHandler(btn_clk); p.Controls.Add(b[i]); } b[0].Location=new Point(10,160); b[1].Location=new Point(10,120); b[4].Location=new Point(10,80); b[7].Location=new Point(10,40); b[2].Location=new Point(50,120); b[5].Location=new Point(50,80); b[8].Location=new Point(50,40); b[3].Location=new Point(90,120); b[6].Location=new Point(90,80); b[9].Location=new Point(90,40); bDot=new Button(); bDot.Size=new Size(25,25); bDot.Location=new Point(50,160); bDot.BackColor=Color.White; bDot.Text="."; bDot.Click+=new EventHandler(btn_clk); bPlus=new Button(); bPlus.Size=new Size(25,25); bPlus.Location=new Point(130,160); bPlus.BackColor=Color.White; bPlus.Text="+"; bPlus.Click+=new EventHandler(btn_Oper); bSub=new Button(); bSub.Size=new Size(25,25); bSub.Location=new Point(130,120); bSub.BackColor=Color.White; bSub.Text="-"; bSub.Click+=new EventHandler(btn_Oper); bMul=new Button(); bMul.Size=new Size(25,25); bMul.Location=new Point(130,80); bMul.BackColor=Color.White; bMul.Text="*"; bMul.Click+=new EventHandler(btn_Oper); bDiv=new Button(); bDiv.Size=new Size(25,25); bDiv.Location=new Point(130,40); bDiv.BackColor=Color.White; bDiv.Text="/"; bDiv.Click+=new EventHandler(btn_Oper); bEqu=new Button();
• 20. bEqu.Size=new Size(25,25); bEqu.Location=new Point(90,160); bEqu.BackColor=Color.White; bEqu.Text="="; bEqu.Click+=new EventHandler(btn_equ); bClr=new Button(); bClr.Size=new Size(20,45); bClr.Location=new Point(170,40); bClr.BackColor=Color.Orange; bClr.Text="AC"; bClr.Click+=new EventHandler(btn_clr); p.Controls.Add(bDot); p.Controls.Add(bPlus); p.Controls.Add(bSub); p.Controls.Add(bMul); p.Controls.Add(bDiv); p.Controls.Add(bEqu); p.Controls.Add(bClr); } private void btn_clk(object obj,EventArgs ea) { if(blnClear) txtCalc.Text=""; Button b3=(Button)obj; txtCalc.Text+=b3.Text; if (txtCalc.Text==".") txtCalc.Text="0."; dblSec=Convert.ToDouble(txtCalc.Text); blnClear=false; } private static void Main() { Application.Run(new win()); } private void btn_Oper(object obj,EventArgs ea) { Button tmp=(Button)obj; strOper=tmp.Text; if (blnFrstOpen) dblAcc=dblSec; else calc(); blnFrstOpen=false; blnClear=true; } private void btn_clr(object obj,EventArgs ea) { clear(); }
• 21. private void btn_equ(object obj,EventArgs ea) { calc(); } private void calc() { switch(strOper) { case "+": dblAcc+=dblSec; break; case "-": dblAcc-=dblSec; break; case "*": dblAcc*=dblSec; break; case "/": dblAcc/=dblSec; break; } strOper="="; blnFrstOpen=true; txtCalc.Text=Convert.ToString(dblAcc); dblSec=dblAcc; } private void clear() { dblAcc=0; dblSec=0; blnFrstOpen=true; txtCalc.Text=""; txtCalc.Focus(); } } 13. Demonstrate Use of Virtual and override key words in C# with a simple program using System; public class Employee { // protected data for kids. protected string fullName; protected int empID; protected float currPay; protected string empSSN; #region Constructors // Default ctor. public Employee(){} // Custom ctor
• 22. public Employee(string FullName, int empID, float currPay) { // Assign internal state data. // Note use of 'this' keyword // to avoid name clashes. this.fullName = FullName; this.empID = empID; this.currPay = currPay; } // If the user calls this ctor, forward to the 4-arg version // using arbitrary values... public Employee(string fullName) : this(fullName, 3333, 0.0F){} #endregion #region Methods // Bump the pay for this emp. public virtual void GiveBonus(float amount) {currPay += amount;} // Show state (could use ToString() as well) public virtual void DisplayStats() { Console.WriteLine("Name: {0}", fullName); Console.WriteLine("Pay: {0}", currPay); Console.WriteLine("ID: {0}", empID); } // Accessor & mutator for the FirstName. public string GetFullName() { return fullName; } public void SetFullName(string n) { // Remove any illegal characters (!,@,#,\$,%), // check maximum length or case before making assignment. fullName = n; } #endregion #region properties // Property for the empID. public int EmpID { get {return empID;} set { #if DEBUG Console.WriteLine("value is an instance of: {0} ", value.GetType()); Console.WriteLine("value as string: {0} ", value.ToString()); #endif empID = value; } }
• 23. // Property for the currPay. public float Pay { get {return currPay;} set {currPay = value;} } // Another property for ssn. public string SSN { get { return empSSN; } } #endregion } public class Manager : Employee { private ulong numberOfOptions; #region Constructors public Manager(){} public Manager(string FullName, int empID, float currPay, ulong numbOfOpts) : base(FullName, empID, currPay) { // This point of data belongs with us! numberOfOptions = numbOfOpts; } #endregion #region Methods and properties public override void GiveBonus(float amount) { // Increase salary. base.GiveBonus(amount); // And give some new stock options... Random r = new Random(); numberOfOptions += (ulong)r.Next(500); } public override void DisplayStats() { base.DisplayStats(); Console.WriteLine("Number of stock options: {0}", numberOfOptions); } public ulong NumbOpts { get {return numberOfOptions;}
• 24. set { numberOfOptions = value;} } #endregion } public class SalesPerson : Employee { protected int numberOfSales; #region Constructors public SalesPerson(){} public SalesPerson(string FullName, int empID, float currPay, int numbOfSales) : base(FullName, empID, currPay) { numberOfSales = numbOfSales; } #endregion #region Properties and methods public int NumbSales { get {return numberOfSales;} set { numberOfSales = value;} } public override void GiveBonus(float amount) { int salesBonus = 0; if(numberOfSales >= 0 && numberOfSales <= 100) salesBonus = 10; else if(numberOfSales >= 101 && numberOfSales <= 200) salesBonus = 15; else salesBonus = 20; // Anything greater than 200. base.GiveBonus(amount * salesBonus); } public override void DisplayStats() { base.DisplayStats(); Console.WriteLine("Number of sales: {0}", numberOfSales); } #endregion } public class Virtual_override { public static void Main() {
• 25. Manager mgr = new Manager("xyz",55,1000,200 ); mgr.GiveBonus(100); mgr.DisplayStats(); SalesPerson sp = new SalesPerson("abc",44,10000,200); sp.GiveBonus(100); sp.DisplayStats(); } } 14. Implement linked lists in C# using the existing collections name space. using System; using System.Collections.Generic; namespace Interview { class Program { static int ListLength = 10; static void Main(string[] args) { // Create a non-circular list ListItem.Head.Data = 0; ListItem i = ListItem.Head; for (int d = 1 ; d < ListLength; d++) { ListItem n = new ListItem(d); i.InsertAfter(n); i = n; } ListItem.PrintToConsole(); Console.WriteLine(); int randpos = new Random().Next(ListLength); Console.WriteLine("Target: {0}", randpos); ListItem target = ListItem.FindData(randpos); target.InsertAfter(new ListItem("InsertAfter")); ListItem.PrintToConsole(); Console.WriteLine(); target.InsertBeforeUsingHead(new ListItem("InsertBeforeUsingHead")); ListItem.PrintToConsole(); Console.WriteLine(); target.InsertBeforeWithoutHead(new ListItem("InsertBeforeWithoutHead")); ListItem.PrintToConsole(); Console.WriteLine(); target = ListItem.FindData(randpos); target.DeleteAfter(); ListItem.PrintToConsole(); Console.WriteLine(); target = target.FindPrevious(); target.DeleteCurrentUsingHead(); ListItem.PrintToConsole(); Console.WriteLine(); target = ListItem.FindData(randpos).FindPrevious(); target.DeleteCurrentWithoutHead();