private void btnByVal_Click(object sender, EventArgs e) { book1 = new Book("Java is fun", "Joe Cool"); book2 = new Book("C# is Cool", "Barclay Benton"); String beforeByVal = "Before By Val" + "\r\n" + "Book 1 = " + book1 + "\r\n" + "Book 2 = " + book2 + "\r\n\r\n"; passBooksByValue(book1,book2); String afterByVal = "After By Val" + "\r\n" + "Book 1 = " + book1 + "\r\n" + "Book 2 = " + book2 + "\r\n\r\n"; txtOutput.Text = beforeByVal + afterByVal; }
private void passBooksByValue(Book b1, Book b2) { // passBooksByValue Book tempBook = new Book("Parameters are easy", "Sally Smitherington"); b1 = tempBook; b2.Title = tempBook.Title; }
private void passBooksByReference(ref Book b1,ref Book b2) { // passBooksByValue Book tempBook2 = new Book("Parameters are easy", "Sally Smitherington"); b1 = tempBook2; b2.Title = tempBook2.Title; }