SlideShare ist ein Scribd-Unternehmen logo
1 von 50
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 1
Chapter 12
How to create
and use classes
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 2
Objectives
Applied
1. Given the specifications for an application that uses classes with
any of the members presented in this chapter, develop the
application and its classes.
2. Use class diagrams, the Class View window, and the Class
Details window to review, delete, and start the members of the
classes in a solution.
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 3
Objectives (continued)
Knowledge
1. List and describe the three layers of a three-layered application.
2. Describe these members of a class: constructor, method, field, and
property.
3. Describe the concept of encapsulation.
4. Explain how instantiation works.
5. Describe the main advantage of using object initializers.
6. Explain how auto-implemented properties work.
7. Describe the concept of overloading a method.
8. Explain what a static member is.
9. Describe the basic procedure for using the Generate From Usage
feature to generate code stubs.
10.Describe the difference between a class and a structure.
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 4
The architecture of a three-layered application
Main Windows
form class
Presentation
layer
Other form
classes
Business
classes
Middle layer
Database
classes
Database layer Database
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 5
The members of a Product class
Properties Description
Code A string that contains a code that uniquely
identifies each product.
Description A string that contains a description of the
product.
Price A decimal that contains the product’s price.
Method Description
GetDisplayText(sep) Returns a string that contains the code,
description, and price in a displayable
format. The sep parameter is a string that’s
used to separate the elements.
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 6
The members of a Product class (continued)
Constructors Description
() Creates a Product object with default values.
(code, description, price)
Creates a Product object using the specified
code, description, and price values.
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 7
Types of class members
Class member Description
Property Represents a data value associated with an object
instance.
Method An operation that can be performed by an object.
Constructor A special type of method that’s executed when an
object is instantiated.
Delegate A special type of object that’s used to wire an
event to a method.
Event A signal that notifies other objects that something
noteworthy has occurred.
Field A variable that’s declared at the class level.
Constant A constant.
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 8
Types of class members (continued)
Class member Description
Indexer A special type of property that allows individual
items within the class to be accessed by index
values. Used for classes that represent collections
of objects.
Operator A special type of method that’s performed for a
C# operator such as + or ==.
Class A class that’s defined within the class.
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 9
Class and object concepts
• An object is a self-contained unit that has properties, methods,
and other members. A class contains the code that defines the
members of an object.
• An object is an instance of a class, and the process of creating an
object is called instantiation.
• Encapsulation is one of the fundamental concepts of object-
oriented programming. It lets you control the data and operations
within a class that are exposed to other classes.
• The data of a class is typically encapsulated within a class using
data hiding. In addition, the code that performs operations within
the class is encapsulated so it can be changed without changing
the way other classes use it.
• Although a class can have many different types of members, most
of the classes you create will have just properties, methods, and
constructors.
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 10
The Product class: Fields and constructors
using System;
namespace ProductMaint
{
public class Product
{
private string code;
private string description;
private decimal price;
public Product(){}
public Product(string code, string description,
decimal price)
{
this.Code = code;
this.Description = description;
this.Price = price;
}
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 11
The Product class: The Code property
public string Code
{
get
{
return code;
}
set
{
code = value;
}
}
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 12
The Product class: The Description property
public string Description
{
get
{
return description;
}
set
{
description = value;
}
}
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 13
The Product class: The Price property and
GetDisplayText method
public decimal Price
{
get
{
return price;
}
set
{
price = value;
}
}
public string GetDisplayText(string sep)
{
return code + sep + price.ToString("c") + sep
+ description;
}
}
}
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 14
Two Product objects that have been instantiated
from the Product class
product1
Code=CS10
Description=
Murach’s C# 2010
Price=54.50
product2
Code=VB10
Description=
Murach’s Visual Basic 2010
Price=54.50
Code that creates these two object instances
Product product1, product2;
product1 = new Product("CS10",
"Murach's C# 2010", 54.50m);
product2 = new Product("VB10",
"Murach's Visual Basic 2010", 54.50m);
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 15
The dialog box for adding a class
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 16
The starting code for the new class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ProductMaintenance
{
class Product
{
}
}
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 17
Examples of field declarations
private int quantity; // A private field.
public decimal Price; // A public field.
public readonly int Limit = 90; // A public read-only field.
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 18
A version of the Product class that uses public
fields instead of properties
public class Product
{
// Public fields
public string Code;
public string Description;
public decimal Price;
public Product()
{
}
public Product(string code, string description,
decimal price)
{
this.Code = code;
this.Description = description;
this.Price = price;
}
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 19
A version of the Product class that uses public
fields instead of properties (continued)
public string GetDisplayText(string sep)
{
return Code + sep + Price.ToString("c") + sep
+ Description;
}
}
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 20
The syntax for coding a public property
public type PropertyName
{
[get { get accessor code }]
[set { set accessor code }]
}
A read/write property
public string Code
{
get
{
return code;
}
set
{
code = value;
}
}
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 21
A read-only property
public decimal DiscountAmount
{
get
{
discountAmount = subtotal * discountPercent;
return discountAmount;
}
}
An auto-implemented property
Public string Code { get; set; }
A statement that sets a property value
product.Code = txtProductCode.Text;
A statement that gets a property value
string code = product.Code;
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 22
The syntax for coding a public method
public returnType MethodName([parameterList])
{
statements
}
A method that accepts parameters
public string GetDisplayText(string sep)
{
return code + sep + price.ToString("c") + sep
+ description;
}
An overloaded version of the GetDisplayText
method
public string GetDisplayText()
{
return code + ", " + price.ToString("c") + ", "
+ description;
}
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 23
Two statements that call the GetDisplayText
method
lblProduct.Text = product.GetDisplayText("t");
lblProduct.Text = product.GetDisplayText();
How the IntelliSense feature lists overloaded
methods
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 24
A constructor with no parameters
public Product()
{
}
A constructor with three parameters
public Product(string code, string description,
decimal price)
{
this.Code = code;
this.Description = description;
this.Price = price;
}
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 25
A constructor with one parameter
public Product(string code)
{
Product p = ProductDB.GetProduct(code);
this.Code = p.Code;
this.Description = p.Description;
this.Price = p.Price;
}
Statements that call the Product constructors
Product product1 = new Product();
Product product2 = new Product("CS10",
"Murach's C# 2010", 54.50m);
Product product3 = new Product(txtCode.Text);
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 26
Default values for instance variables
Data type Default value
All numeric types zero (0)
Boolean false
Char binary 0 (null)
Object null (no value)
Date 12:00 a.m. on January 1, 0001
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 27
A class that contains static members
public static class Validator
{
private static string title = "Entry Error";
public static string Title
{
get
{
return title;
}
set
{
title = value;
}
}
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 28
A class that contains static members (continued)
public static bool IsPresent(TextBox textBox)
{
if (textBox.Text == "")
{
MessageBox.Show(textBox.Tag
+ " is a required field.", Title);
textBox.Focus();
return false;
}
return true;
}
Code that uses static members
if ( Validator.IsPresent(txtCode) &&
Validator.IsPresent(txtDescription) &&
Validator.IsPresent(txtPrice) )
isValidData = true;
else
isValidData = false;
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 29
Right-clicking on an undefined name to generate
a class
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 30
Using a smart tag menu to generate a method
stub
The generated code
class Product
{
internal decimal GetPrice(string p)
{
throw new NotImplementedException();
}
}
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 31
The Product Maintenance form
The New Product form
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 32
The Tag property settings for the
text boxes on the New Product form
Control Tag property setting
txtCode Code
txtDescription Description
txtPrice Price
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 33
The Product class
Property Description
Code A string that contains a code that uniquely identifies
the product.
Description A string that contains a description of the product.
Price A decimal that contains the product’s price.
Method Description
GetDisplayText(sep)
Returns a string that contains the code, description,
and price separated by the sep string.
Constructor Description
() Creates a Product object with default values.
(code, description, price)
Creates a Product object using the specified values.
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 34
The ProductDB class
Method Description
GetProducts() A static method that returns a List<> of
Product objects from the Products file.
SaveProducts(list) A static method that writes the products in the
specified List<> of Product objects to the
Products file.
Note
• You don’t need to know how the ProductDB class works. You just
need to know about its methods so you can use them in your code.
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 35
The Validator class
Property Description
Title A static string; contains the text that’s
displayed in the title bar of a dialog box for an
error message.
Static method Returns a Boolean value that indicates
whether…
IsPresent(textBox) Data was entered into the text box.
IsInt32(textBox) An integer was entered into the text box.
IsDecimal(textBox) A decimal was entered into the text box.
IsWithinRange(textBox, min, max)
The value entered into the text box is within
the specified range.
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 36
The code for the Product Maintenance form
public partial class frmProductMain : Form
{
public frmProductMain()
{
InitializeComponent();
}
private List<Product> products = null;
private void frmProductMain_Load(object sender,
System.EventArgs e)
{
products = ProductDB.GetProducts();
FillProductListBox();
}
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 37
The Product Maintenance form (continued)
private void FillProductListBox()
{
lstProducts.Items.Clear();
foreach (Product p in products)
{
lstProducts.Items.Add(p.GetDisplayText("t"));
}
}
private void btnAdd_Click(object sender,
System.EventArgs e)
{
frmNewProduct newProductForm = new frmNewProduct();
Product product = newProductForm.GetNewProduct();
if (product != null)
{
products.Add(product);
ProductDB.SaveProducts(products);
FillProductListBox();
}
}
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 38
The Product Maintenance form (continued)
private void btnDelete_Click(object sender,
System.EventArgs e)
{
int i = lstProducts.SelectedIndex;
if (i != -1)
{
Product product = products[i];
string message =
"Are you sure you want to delete "
+ product.Description + "?";
DialogResult button =
MessageBox.Show(message, "Confirm Delete",
MessageBoxButtons.YesNo);
if (button == DialogResult.Yes)
{
products.Remove(product);
ProductDB.SaveProducts(products);
FillProductListBox();
}
}
}
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 39
The Product Maintenance form (continued)
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
}
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 40
The code for the New Product form
public partial class frmNewProduct : Form
{
public frmNewProduct()
{
InitializeComponent();
}
private Product product = null;
public Product GetNewProduct()
{
this.ShowDialog();
return product;
}
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 41
The New Product form (continued)
private void btnSave_Click(object sender,
System.EventArgs e)
{
if (IsValidData())
{
product = new Product(txtCode.Text,
txtDescription.Text,
Convert.ToDecimal(txtPrice.Text));
this.Close();
}
}
private bool IsValidData()
{
return Validator.IsPresent(txtCode) &&
Validator.IsPresent(txtDescription) &&
Validator.IsPresent(txtPrice) &&
Validator.IsDecimal(txtPrice);
}
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 42
The New Product form (continued)
private void btnCancel_Click(object sender,
System.EventArgs e)
{
this.Close();
}
}
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 43
The code for the Validator class
public static class Validator
{
private static string title = "Entry Error";
public static string Title
{
get
{
return title;
}
set
{
title = value;
}
}
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 44
The Validator class (continued)
public static bool IsPresent(TextBox textBox)
{
if (textBox.Text == "")
{
MessageBox.Show(textBox.Tag
+ " is a required field.", Title);
textBox.Focus();
return false;
}
return true;
}
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 45
The Validator class (continued)
public static bool IsDecimal(TextBox textBox)
{
try
{
Convert.ToDecimal(textBox.Text);
return true;
}
catch (FormatException)
{
MessageBox.Show(textBox.Tag
+ " must be a decimal number.", Title);
textBox.Focus();
return false;
}
}
}
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 46
The Class View window
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 47
A class diagram that shows two of the classes*
*Express Edition doesn’t have class diagrams or the Class Details window
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 48
The syntax for creating a structure
public struct StructureName
{
structure members...
}
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 49
A Product structure
public struct Product
{
public string Code;
public string Description;
public decimal Price;
public Product(string code, string description,
decimal price)
{
this.Code = code;
this.Description = description;
this.Price = price;
}
public string GetDisplayText(string sep)
{
return Code + sep + Price.ToString("c") + sep
+ Description;
}
}
Murach’s C#
2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 50
Code that declares a variable as a structure type and
assigns values to it
Product p; // Create an instance of the Product structure
p.Code = "CS10"; // Assign values to each instance variable
p.Description = "Murach's C# 2010";
p.Price = 54.50m;
string msg = p.GetDisplayText("n"); // Call a method
Code that uses the structure’s constructor
Product p = new Product("CS10", "Murach's C# 2010", 54.50m);

Weitere ähnliche Inhalte

Was ist angesagt?

JAVA GUI PART I
JAVA GUI PART IJAVA GUI PART I
JAVA GUI PART IOXUS 20
 
JavaScript Objects
JavaScript ObjectsJavaScript Objects
JavaScript ObjectsReem Alattas
 
Multichannel User Interfaces
Multichannel User InterfacesMultichannel User Interfaces
Multichannel User InterfacesIcinetic
 
Synopsis for student interaction portal
Synopsis for student interaction portalSynopsis for student interaction portal
Synopsis for student interaction portalmukesh Chettri
 
Design Pattern - Chain of Responsibility
Design Pattern - Chain of ResponsibilityDesign Pattern - Chain of Responsibility
Design Pattern - Chain of ResponsibilityMudasir Qazi
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQueryZeeshan Khan
 
Html events with javascript
Html events with javascriptHtml events with javascript
Html events with javascriptYounusS2
 
Refactoring and code smells
Refactoring and code smellsRefactoring and code smells
Refactoring and code smellsPaul Nguyen
 
Java Thread Synchronization
Java Thread SynchronizationJava Thread Synchronization
Java Thread SynchronizationBenj Del Mundo
 
Windows Forms For Beginners Part - 1
Windows Forms For Beginners Part - 1Windows Forms For Beginners Part - 1
Windows Forms For Beginners Part - 1Bhushan Mulmule
 
Advance Java Programming(CM5I) Event handling
Advance Java Programming(CM5I) Event handlingAdvance Java Programming(CM5I) Event handling
Advance Java Programming(CM5I) Event handlingPayal Dungarwal
 
Strategy Pattern
Strategy PatternStrategy Pattern
Strategy PatternGuo Albert
 
Windows form application - C# Training
Windows form application - C# Training Windows form application - C# Training
Windows form application - C# Training Moutasm Tamimi
 

Was ist angesagt? (20)

JAVA GUI PART I
JAVA GUI PART IJAVA GUI PART I
JAVA GUI PART I
 
JavaScript Objects
JavaScript ObjectsJavaScript Objects
JavaScript Objects
 
Multichannel User Interfaces
Multichannel User InterfacesMultichannel User Interfaces
Multichannel User Interfaces
 
Synopsis for student interaction portal
Synopsis for student interaction portalSynopsis for student interaction portal
Synopsis for student interaction portal
 
JSON and XML
JSON and XMLJSON and XML
JSON and XML
 
Design Pattern - Chain of Responsibility
Design Pattern - Chain of ResponsibilityDesign Pattern - Chain of Responsibility
Design Pattern - Chain of Responsibility
 
4.C#
4.C#4.C#
4.C#
 
Jquery
JqueryJquery
Jquery
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
Textbox n label
Textbox n labelTextbox n label
Textbox n label
 
Input Validation
Input ValidationInput Validation
Input Validation
 
Html events with javascript
Html events with javascriptHtml events with javascript
Html events with javascript
 
Refactoring and code smells
Refactoring and code smellsRefactoring and code smells
Refactoring and code smells
 
Java Thread Synchronization
Java Thread SynchronizationJava Thread Synchronization
Java Thread Synchronization
 
Windows Forms For Beginners Part - 1
Windows Forms For Beginners Part - 1Windows Forms For Beginners Part - 1
Windows Forms For Beginners Part - 1
 
reactJS
reactJSreactJS
reactJS
 
Advance Java Programming(CM5I) Event handling
Advance Java Programming(CM5I) Event handlingAdvance Java Programming(CM5I) Event handling
Advance Java Programming(CM5I) Event handling
 
Strategy Pattern
Strategy PatternStrategy Pattern
Strategy Pattern
 
Windows form application - C# Training
Windows form application - C# Training Windows form application - C# Training
Windows form application - C# Training
 
Visual basic
Visual basicVisual basic
Visual basic
 

Andere mochten auch

C# Tutorial MSM_Murach chapter-13-slides
C# Tutorial MSM_Murach chapter-13-slidesC# Tutorial MSM_Murach chapter-13-slides
C# Tutorial MSM_Murach chapter-13-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-07-slides
C# Tutorial MSM_Murach chapter-07-slidesC# Tutorial MSM_Murach chapter-07-slides
C# Tutorial MSM_Murach chapter-07-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-09-slides
C# Tutorial MSM_Murach chapter-09-slidesC# Tutorial MSM_Murach chapter-09-slides
C# Tutorial MSM_Murach chapter-09-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-14-slides
C# Tutorial MSM_Murach chapter-14-slidesC# Tutorial MSM_Murach chapter-14-slides
C# Tutorial MSM_Murach chapter-14-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-08-slides
C# Tutorial MSM_Murach chapter-08-slidesC# Tutorial MSM_Murach chapter-08-slides
C# Tutorial MSM_Murach chapter-08-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-23-slides
C# Tutorial MSM_Murach chapter-23-slidesC# Tutorial MSM_Murach chapter-23-slides
C# Tutorial MSM_Murach chapter-23-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-01-slides
C# Tutorial MSM_Murach chapter-01-slidesC# Tutorial MSM_Murach chapter-01-slides
C# Tutorial MSM_Murach chapter-01-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-02-slides
C# Tutorial MSM_Murach chapter-02-slidesC# Tutorial MSM_Murach chapter-02-slides
C# Tutorial MSM_Murach chapter-02-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-03-slides
C# Tutorial MSM_Murach chapter-03-slidesC# Tutorial MSM_Murach chapter-03-slides
C# Tutorial MSM_Murach chapter-03-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-15-slides
C# Tutorial MSM_Murach chapter-15-slidesC# Tutorial MSM_Murach chapter-15-slides
C# Tutorial MSM_Murach chapter-15-slidesSami Mut
 
Learn C# Programming - Data Types & Type Conversion
Learn C# Programming - Data Types & Type ConversionLearn C# Programming - Data Types & Type Conversion
Learn C# Programming - Data Types & Type ConversionEng Teong Cheah
 
Mecalux Best Practices Magazine 01 - English
Mecalux Best Practices Magazine 01 - EnglishMecalux Best Practices Magazine 01 - English
Mecalux Best Practices Magazine 01 - EnglishMecalux
 
C# Tutorial MSM_Murach chapter-19-slides
C# Tutorial MSM_Murach chapter-19-slidesC# Tutorial MSM_Murach chapter-19-slides
C# Tutorial MSM_Murach chapter-19-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-20-slides
C# Tutorial MSM_Murach chapter-20-slidesC# Tutorial MSM_Murach chapter-20-slides
C# Tutorial MSM_Murach chapter-20-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-16-slides
C# Tutorial MSM_Murach chapter-16-slidesC# Tutorial MSM_Murach chapter-16-slides
C# Tutorial MSM_Murach chapter-16-slidesSami Mut
 
DevDay Salerno - Introduzione a Xamarin
DevDay Salerno - Introduzione a XamarinDevDay Salerno - Introduzione a Xamarin
DevDay Salerno - Introduzione a XamarinAntonio Liccardi
 

Andere mochten auch (20)

C# Tutorial MSM_Murach chapter-13-slides
C# Tutorial MSM_Murach chapter-13-slidesC# Tutorial MSM_Murach chapter-13-slides
C# Tutorial MSM_Murach chapter-13-slides
 
C# Tutorial MSM_Murach chapter-07-slides
C# Tutorial MSM_Murach chapter-07-slidesC# Tutorial MSM_Murach chapter-07-slides
C# Tutorial MSM_Murach chapter-07-slides
 
C# Tutorial MSM_Murach chapter-09-slides
C# Tutorial MSM_Murach chapter-09-slidesC# Tutorial MSM_Murach chapter-09-slides
C# Tutorial MSM_Murach chapter-09-slides
 
C# Tutorial MSM_Murach chapter-14-slides
C# Tutorial MSM_Murach chapter-14-slidesC# Tutorial MSM_Murach chapter-14-slides
C# Tutorial MSM_Murach chapter-14-slides
 
C# Tutorial MSM_Murach chapter-08-slides
C# Tutorial MSM_Murach chapter-08-slidesC# Tutorial MSM_Murach chapter-08-slides
C# Tutorial MSM_Murach chapter-08-slides
 
C# Tutorial MSM_Murach chapter-23-slides
C# Tutorial MSM_Murach chapter-23-slidesC# Tutorial MSM_Murach chapter-23-slides
C# Tutorial MSM_Murach chapter-23-slides
 
C# Tutorial MSM_Murach chapter-01-slides
C# Tutorial MSM_Murach chapter-01-slidesC# Tutorial MSM_Murach chapter-01-slides
C# Tutorial MSM_Murach chapter-01-slides
 
C# Tutorial MSM_Murach chapter-02-slides
C# Tutorial MSM_Murach chapter-02-slidesC# Tutorial MSM_Murach chapter-02-slides
C# Tutorial MSM_Murach chapter-02-slides
 
C# Tutorial MSM_Murach chapter-03-slides
C# Tutorial MSM_Murach chapter-03-slidesC# Tutorial MSM_Murach chapter-03-slides
C# Tutorial MSM_Murach chapter-03-slides
 
C# Tutorial MSM_Murach chapter-15-slides
C# Tutorial MSM_Murach chapter-15-slidesC# Tutorial MSM_Murach chapter-15-slides
C# Tutorial MSM_Murach chapter-15-slides
 
Learn C# Programming - Data Types & Type Conversion
Learn C# Programming - Data Types & Type ConversionLearn C# Programming - Data Types & Type Conversion
Learn C# Programming - Data Types & Type Conversion
 
Mecalux Best Practices Magazine 01 - English
Mecalux Best Practices Magazine 01 - EnglishMecalux Best Practices Magazine 01 - English
Mecalux Best Practices Magazine 01 - English
 
Sedev 1
Sedev 1Sedev 1
Sedev 1
 
Lec1
Lec1Lec1
Lec1
 
2017 xamarin
2017 xamarin2017 xamarin
2017 xamarin
 
C# Tutorial MSM_Murach chapter-19-slides
C# Tutorial MSM_Murach chapter-19-slidesC# Tutorial MSM_Murach chapter-19-slides
C# Tutorial MSM_Murach chapter-19-slides
 
Lesson 3: Variables and Expressions
Lesson 3: Variables and ExpressionsLesson 3: Variables and Expressions
Lesson 3: Variables and Expressions
 
C# Tutorial MSM_Murach chapter-20-slides
C# Tutorial MSM_Murach chapter-20-slidesC# Tutorial MSM_Murach chapter-20-slides
C# Tutorial MSM_Murach chapter-20-slides
 
C# Tutorial MSM_Murach chapter-16-slides
C# Tutorial MSM_Murach chapter-16-slidesC# Tutorial MSM_Murach chapter-16-slides
C# Tutorial MSM_Murach chapter-16-slides
 
DevDay Salerno - Introduzione a Xamarin
DevDay Salerno - Introduzione a XamarinDevDay Salerno - Introduzione a Xamarin
DevDay Salerno - Introduzione a Xamarin
 

Ähnlich wie C# Classes Guidebook: How to Create and Use Classes in C# Applications

C# Tutorial MSM_Murach chapter-10-slides
C# Tutorial MSM_Murach chapter-10-slidesC# Tutorial MSM_Murach chapter-10-slides
C# Tutorial MSM_Murach chapter-10-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-18-slides
C# Tutorial MSM_Murach chapter-18-slidesC# Tutorial MSM_Murach chapter-18-slides
C# Tutorial MSM_Murach chapter-18-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-24-slides
C# Tutorial MSM_Murach chapter-24-slidesC# Tutorial MSM_Murach chapter-24-slides
C# Tutorial MSM_Murach chapter-24-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-21-slides
C# Tutorial MSM_Murach chapter-21-slidesC# Tutorial MSM_Murach chapter-21-slides
C# Tutorial MSM_Murach chapter-21-slidesSami Mut
 
22316-2019-Summer-model-answer-paper.pdf
22316-2019-Summer-model-answer-paper.pdf22316-2019-Summer-model-answer-paper.pdf
22316-2019-Summer-model-answer-paper.pdfPradipShinde53
 
.NET Portfolio
.NET Portfolio.NET Portfolio
.NET Portfoliomwillmer
 
C# Tutorial MSM_Murach chapter-22-slides
C# Tutorial MSM_Murach chapter-22-slidesC# Tutorial MSM_Murach chapter-22-slides
C# Tutorial MSM_Murach chapter-22-slidesSami Mut
 
Intro to iOS Development • Made by Many
Intro to iOS Development • Made by ManyIntro to iOS Development • Made by Many
Intro to iOS Development • Made by Manykenatmxm
 
Module 2: C# 3.0 Language Enhancements (Material)
Module 2: C# 3.0 Language Enhancements (Material)Module 2: C# 3.0 Language Enhancements (Material)
Module 2: C# 3.0 Language Enhancements (Material)Mohamed Saleh
 
I assignmnt(oops)
I assignmnt(oops)I assignmnt(oops)
I assignmnt(oops)Jay Patel
 
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010vchircu
 
classes object fgfhdfgfdgfgfgfgfdoop.pptx
classes object  fgfhdfgfdgfgfgfgfdoop.pptxclasses object  fgfhdfgfdgfgfgfgfdoop.pptx
classes object fgfhdfgfdgfgfgfgfdoop.pptxarjun431527
 

Ähnlich wie C# Classes Guidebook: How to Create and Use Classes in C# Applications (20)

C# Tutorial MSM_Murach chapter-10-slides
C# Tutorial MSM_Murach chapter-10-slidesC# Tutorial MSM_Murach chapter-10-slides
C# Tutorial MSM_Murach chapter-10-slides
 
C# Tutorial MSM_Murach chapter-18-slides
C# Tutorial MSM_Murach chapter-18-slidesC# Tutorial MSM_Murach chapter-18-slides
C# Tutorial MSM_Murach chapter-18-slides
 
C# Tutorial MSM_Murach chapter-24-slides
C# Tutorial MSM_Murach chapter-24-slidesC# Tutorial MSM_Murach chapter-24-slides
C# Tutorial MSM_Murach chapter-24-slides
 
C# Tutorial MSM_Murach chapter-21-slides
C# Tutorial MSM_Murach chapter-21-slidesC# Tutorial MSM_Murach chapter-21-slides
C# Tutorial MSM_Murach chapter-21-slides
 
22316-2019-Summer-model-answer-paper.pdf
22316-2019-Summer-model-answer-paper.pdf22316-2019-Summer-model-answer-paper.pdf
22316-2019-Summer-model-answer-paper.pdf
 
.NET Portfolio
.NET Portfolio.NET Portfolio
.NET Portfolio
 
C# Tutorial MSM_Murach chapter-22-slides
C# Tutorial MSM_Murach chapter-22-slidesC# Tutorial MSM_Murach chapter-22-slides
C# Tutorial MSM_Murach chapter-22-slides
 
VR Workshop #2
VR Workshop #2VR Workshop #2
VR Workshop #2
 
Intro to iOS Development • Made by Many
Intro to iOS Development • Made by ManyIntro to iOS Development • Made by Many
Intro to iOS Development • Made by Many
 
Module 2: C# 3.0 Language Enhancements (Material)
Module 2: C# 3.0 Language Enhancements (Material)Module 2: C# 3.0 Language Enhancements (Material)
Module 2: C# 3.0 Language Enhancements (Material)
 
Express 070 536
Express 070 536Express 070 536
Express 070 536
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Mvc acchitecture
Mvc acchitectureMvc acchitecture
Mvc acchitecture
 
I assignmnt(oops)
I assignmnt(oops)I assignmnt(oops)
I assignmnt(oops)
 
Ch03
Ch03Ch03
Ch03
 
Ch03
Ch03Ch03
Ch03
 
Pratk kambe rac
Pratk kambe racPratk kambe rac
Pratk kambe rac
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
 
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
 
classes object fgfhdfgfdgfgfgfgfdoop.pptx
classes object  fgfhdfgfdgfgfgfgfdoop.pptxclasses object  fgfhdfgfdgfgfgfgfdoop.pptx
classes object fgfhdfgfdgfgfgfgfdoop.pptx
 

Mehr von Sami Mut

C# Tutorial MSM_Murach chapter-25-slides
C# Tutorial MSM_Murach chapter-25-slidesC# Tutorial MSM_Murach chapter-25-slides
C# Tutorial MSM_Murach chapter-25-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-17-slides
C# Tutorial MSM_Murach chapter-17-slidesC# Tutorial MSM_Murach chapter-17-slides
C# Tutorial MSM_Murach chapter-17-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-11-slides
C# Tutorial MSM_Murach chapter-11-slidesC# Tutorial MSM_Murach chapter-11-slides
C# Tutorial MSM_Murach chapter-11-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-04-slides
C# Tutorial MSM_Murach chapter-04-slidesC# Tutorial MSM_Murach chapter-04-slides
C# Tutorial MSM_Murach chapter-04-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-06-slides
C# Tutorial MSM_Murach chapter-06-slidesC# Tutorial MSM_Murach chapter-06-slides
C# Tutorial MSM_Murach chapter-06-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-05-slides
C# Tutorial MSM_Murach chapter-05-slidesC# Tutorial MSM_Murach chapter-05-slides
C# Tutorial MSM_Murach chapter-05-slidesSami Mut
 
chapter 5 Java at rupp cambodia
chapter 5 Java at rupp cambodiachapter 5 Java at rupp cambodia
chapter 5 Java at rupp cambodiaSami Mut
 
chapter 2 Java at rupp cambodia
chapter 2 Java at rupp cambodiachapter 2 Java at rupp cambodia
chapter 2 Java at rupp cambodiaSami Mut
 
chapter 3 Java at rupp cambodia
chapter 3 Java at rupp cambodiachapter 3 Java at rupp cambodia
chapter 3 Java at rupp cambodiaSami Mut
 
chapter 2 Java at rupp cambodia
chapter 2 Java at rupp cambodiachapter 2 Java at rupp cambodia
chapter 2 Java at rupp cambodiaSami Mut
 
chapter 1 Java at rupp cambodia
chapter 1 Java at rupp cambodiachapter 1 Java at rupp cambodia
chapter 1 Java at rupp cambodiaSami Mut
 

Mehr von Sami Mut (12)

C# Tutorial MSM_Murach chapter-25-slides
C# Tutorial MSM_Murach chapter-25-slidesC# Tutorial MSM_Murach chapter-25-slides
C# Tutorial MSM_Murach chapter-25-slides
 
C# Tutorial MSM_Murach chapter-17-slides
C# Tutorial MSM_Murach chapter-17-slidesC# Tutorial MSM_Murach chapter-17-slides
C# Tutorial MSM_Murach chapter-17-slides
 
C# Tutorial MSM_Murach chapter-11-slides
C# Tutorial MSM_Murach chapter-11-slidesC# Tutorial MSM_Murach chapter-11-slides
C# Tutorial MSM_Murach chapter-11-slides
 
C# Tutorial MSM_Murach chapter-04-slides
C# Tutorial MSM_Murach chapter-04-slidesC# Tutorial MSM_Murach chapter-04-slides
C# Tutorial MSM_Murach chapter-04-slides
 
C# Tutorial MSM_Murach chapter-06-slides
C# Tutorial MSM_Murach chapter-06-slidesC# Tutorial MSM_Murach chapter-06-slides
C# Tutorial MSM_Murach chapter-06-slides
 
C# Tutorial MSM_Murach chapter-05-slides
C# Tutorial MSM_Murach chapter-05-slidesC# Tutorial MSM_Murach chapter-05-slides
C# Tutorial MSM_Murach chapter-05-slides
 
MSM_Time
MSM_TimeMSM_Time
MSM_Time
 
chapter 5 Java at rupp cambodia
chapter 5 Java at rupp cambodiachapter 5 Java at rupp cambodia
chapter 5 Java at rupp cambodia
 
chapter 2 Java at rupp cambodia
chapter 2 Java at rupp cambodiachapter 2 Java at rupp cambodia
chapter 2 Java at rupp cambodia
 
chapter 3 Java at rupp cambodia
chapter 3 Java at rupp cambodiachapter 3 Java at rupp cambodia
chapter 3 Java at rupp cambodia
 
chapter 2 Java at rupp cambodia
chapter 2 Java at rupp cambodiachapter 2 Java at rupp cambodia
chapter 2 Java at rupp cambodia
 
chapter 1 Java at rupp cambodia
chapter 1 Java at rupp cambodiachapter 1 Java at rupp cambodia
chapter 1 Java at rupp cambodia
 

Kürzlich hochgeladen

UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 

Kürzlich hochgeladen (20)

UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 

C# Classes Guidebook: How to Create and Use Classes in C# Applications

  • 1. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 1 Chapter 12 How to create and use classes
  • 2. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 2 Objectives Applied 1. Given the specifications for an application that uses classes with any of the members presented in this chapter, develop the application and its classes. 2. Use class diagrams, the Class View window, and the Class Details window to review, delete, and start the members of the classes in a solution.
  • 3. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 3 Objectives (continued) Knowledge 1. List and describe the three layers of a three-layered application. 2. Describe these members of a class: constructor, method, field, and property. 3. Describe the concept of encapsulation. 4. Explain how instantiation works. 5. Describe the main advantage of using object initializers. 6. Explain how auto-implemented properties work. 7. Describe the concept of overloading a method. 8. Explain what a static member is. 9. Describe the basic procedure for using the Generate From Usage feature to generate code stubs. 10.Describe the difference between a class and a structure.
  • 4. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 4 The architecture of a three-layered application Main Windows form class Presentation layer Other form classes Business classes Middle layer Database classes Database layer Database
  • 5. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 5 The members of a Product class Properties Description Code A string that contains a code that uniquely identifies each product. Description A string that contains a description of the product. Price A decimal that contains the product’s price. Method Description GetDisplayText(sep) Returns a string that contains the code, description, and price in a displayable format. The sep parameter is a string that’s used to separate the elements.
  • 6. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 6 The members of a Product class (continued) Constructors Description () Creates a Product object with default values. (code, description, price) Creates a Product object using the specified code, description, and price values.
  • 7. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 7 Types of class members Class member Description Property Represents a data value associated with an object instance. Method An operation that can be performed by an object. Constructor A special type of method that’s executed when an object is instantiated. Delegate A special type of object that’s used to wire an event to a method. Event A signal that notifies other objects that something noteworthy has occurred. Field A variable that’s declared at the class level. Constant A constant.
  • 8. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 8 Types of class members (continued) Class member Description Indexer A special type of property that allows individual items within the class to be accessed by index values. Used for classes that represent collections of objects. Operator A special type of method that’s performed for a C# operator such as + or ==. Class A class that’s defined within the class.
  • 9. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 9 Class and object concepts • An object is a self-contained unit that has properties, methods, and other members. A class contains the code that defines the members of an object. • An object is an instance of a class, and the process of creating an object is called instantiation. • Encapsulation is one of the fundamental concepts of object- oriented programming. It lets you control the data and operations within a class that are exposed to other classes. • The data of a class is typically encapsulated within a class using data hiding. In addition, the code that performs operations within the class is encapsulated so it can be changed without changing the way other classes use it. • Although a class can have many different types of members, most of the classes you create will have just properties, methods, and constructors.
  • 10. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 10 The Product class: Fields and constructors using System; namespace ProductMaint { public class Product { private string code; private string description; private decimal price; public Product(){} public Product(string code, string description, decimal price) { this.Code = code; this.Description = description; this.Price = price; }
  • 11. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 11 The Product class: The Code property public string Code { get { return code; } set { code = value; } }
  • 12. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 12 The Product class: The Description property public string Description { get { return description; } set { description = value; } }
  • 13. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 13 The Product class: The Price property and GetDisplayText method public decimal Price { get { return price; } set { price = value; } } public string GetDisplayText(string sep) { return code + sep + price.ToString("c") + sep + description; } } }
  • 14. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 14 Two Product objects that have been instantiated from the Product class product1 Code=CS10 Description= Murach’s C# 2010 Price=54.50 product2 Code=VB10 Description= Murach’s Visual Basic 2010 Price=54.50 Code that creates these two object instances Product product1, product2; product1 = new Product("CS10", "Murach's C# 2010", 54.50m); product2 = new Product("VB10", "Murach's Visual Basic 2010", 54.50m);
  • 15. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 15 The dialog box for adding a class
  • 16. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 16 The starting code for the new class using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ProductMaintenance { class Product { } }
  • 17. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 17 Examples of field declarations private int quantity; // A private field. public decimal Price; // A public field. public readonly int Limit = 90; // A public read-only field.
  • 18. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 18 A version of the Product class that uses public fields instead of properties public class Product { // Public fields public string Code; public string Description; public decimal Price; public Product() { } public Product(string code, string description, decimal price) { this.Code = code; this.Description = description; this.Price = price; }
  • 19. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 19 A version of the Product class that uses public fields instead of properties (continued) public string GetDisplayText(string sep) { return Code + sep + Price.ToString("c") + sep + Description; } }
  • 20. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 20 The syntax for coding a public property public type PropertyName { [get { get accessor code }] [set { set accessor code }] } A read/write property public string Code { get { return code; } set { code = value; } }
  • 21. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 21 A read-only property public decimal DiscountAmount { get { discountAmount = subtotal * discountPercent; return discountAmount; } } An auto-implemented property Public string Code { get; set; } A statement that sets a property value product.Code = txtProductCode.Text; A statement that gets a property value string code = product.Code;
  • 22. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 22 The syntax for coding a public method public returnType MethodName([parameterList]) { statements } A method that accepts parameters public string GetDisplayText(string sep) { return code + sep + price.ToString("c") + sep + description; } An overloaded version of the GetDisplayText method public string GetDisplayText() { return code + ", " + price.ToString("c") + ", " + description; }
  • 23. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 23 Two statements that call the GetDisplayText method lblProduct.Text = product.GetDisplayText("t"); lblProduct.Text = product.GetDisplayText(); How the IntelliSense feature lists overloaded methods
  • 24. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 24 A constructor with no parameters public Product() { } A constructor with three parameters public Product(string code, string description, decimal price) { this.Code = code; this.Description = description; this.Price = price; }
  • 25. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 25 A constructor with one parameter public Product(string code) { Product p = ProductDB.GetProduct(code); this.Code = p.Code; this.Description = p.Description; this.Price = p.Price; } Statements that call the Product constructors Product product1 = new Product(); Product product2 = new Product("CS10", "Murach's C# 2010", 54.50m); Product product3 = new Product(txtCode.Text);
  • 26. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 26 Default values for instance variables Data type Default value All numeric types zero (0) Boolean false Char binary 0 (null) Object null (no value) Date 12:00 a.m. on January 1, 0001
  • 27. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 27 A class that contains static members public static class Validator { private static string title = "Entry Error"; public static string Title { get { return title; } set { title = value; } }
  • 28. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 28 A class that contains static members (continued) public static bool IsPresent(TextBox textBox) { if (textBox.Text == "") { MessageBox.Show(textBox.Tag + " is a required field.", Title); textBox.Focus(); return false; } return true; } Code that uses static members if ( Validator.IsPresent(txtCode) && Validator.IsPresent(txtDescription) && Validator.IsPresent(txtPrice) ) isValidData = true; else isValidData = false;
  • 29. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 29 Right-clicking on an undefined name to generate a class
  • 30. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 30 Using a smart tag menu to generate a method stub The generated code class Product { internal decimal GetPrice(string p) { throw new NotImplementedException(); } }
  • 31. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 31 The Product Maintenance form The New Product form
  • 32. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 32 The Tag property settings for the text boxes on the New Product form Control Tag property setting txtCode Code txtDescription Description txtPrice Price
  • 33. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 33 The Product class Property Description Code A string that contains a code that uniquely identifies the product. Description A string that contains a description of the product. Price A decimal that contains the product’s price. Method Description GetDisplayText(sep) Returns a string that contains the code, description, and price separated by the sep string. Constructor Description () Creates a Product object with default values. (code, description, price) Creates a Product object using the specified values.
  • 34. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 34 The ProductDB class Method Description GetProducts() A static method that returns a List<> of Product objects from the Products file. SaveProducts(list) A static method that writes the products in the specified List<> of Product objects to the Products file. Note • You don’t need to know how the ProductDB class works. You just need to know about its methods so you can use them in your code.
  • 35. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 35 The Validator class Property Description Title A static string; contains the text that’s displayed in the title bar of a dialog box for an error message. Static method Returns a Boolean value that indicates whether… IsPresent(textBox) Data was entered into the text box. IsInt32(textBox) An integer was entered into the text box. IsDecimal(textBox) A decimal was entered into the text box. IsWithinRange(textBox, min, max) The value entered into the text box is within the specified range.
  • 36. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 36 The code for the Product Maintenance form public partial class frmProductMain : Form { public frmProductMain() { InitializeComponent(); } private List<Product> products = null; private void frmProductMain_Load(object sender, System.EventArgs e) { products = ProductDB.GetProducts(); FillProductListBox(); }
  • 37. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 37 The Product Maintenance form (continued) private void FillProductListBox() { lstProducts.Items.Clear(); foreach (Product p in products) { lstProducts.Items.Add(p.GetDisplayText("t")); } } private void btnAdd_Click(object sender, System.EventArgs e) { frmNewProduct newProductForm = new frmNewProduct(); Product product = newProductForm.GetNewProduct(); if (product != null) { products.Add(product); ProductDB.SaveProducts(products); FillProductListBox(); } }
  • 38. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 38 The Product Maintenance form (continued) private void btnDelete_Click(object sender, System.EventArgs e) { int i = lstProducts.SelectedIndex; if (i != -1) { Product product = products[i]; string message = "Are you sure you want to delete " + product.Description + "?"; DialogResult button = MessageBox.Show(message, "Confirm Delete", MessageBoxButtons.YesNo); if (button == DialogResult.Yes) { products.Remove(product); ProductDB.SaveProducts(products); FillProductListBox(); } } }
  • 39. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 39 The Product Maintenance form (continued) private void btnExit_Click(object sender, EventArgs e) { this.Close(); } }
  • 40. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 40 The code for the New Product form public partial class frmNewProduct : Form { public frmNewProduct() { InitializeComponent(); } private Product product = null; public Product GetNewProduct() { this.ShowDialog(); return product; }
  • 41. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 41 The New Product form (continued) private void btnSave_Click(object sender, System.EventArgs e) { if (IsValidData()) { product = new Product(txtCode.Text, txtDescription.Text, Convert.ToDecimal(txtPrice.Text)); this.Close(); } } private bool IsValidData() { return Validator.IsPresent(txtCode) && Validator.IsPresent(txtDescription) && Validator.IsPresent(txtPrice) && Validator.IsDecimal(txtPrice); }
  • 42. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 42 The New Product form (continued) private void btnCancel_Click(object sender, System.EventArgs e) { this.Close(); } }
  • 43. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 43 The code for the Validator class public static class Validator { private static string title = "Entry Error"; public static string Title { get { return title; } set { title = value; } }
  • 44. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 44 The Validator class (continued) public static bool IsPresent(TextBox textBox) { if (textBox.Text == "") { MessageBox.Show(textBox.Tag + " is a required field.", Title); textBox.Focus(); return false; } return true; }
  • 45. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 45 The Validator class (continued) public static bool IsDecimal(TextBox textBox) { try { Convert.ToDecimal(textBox.Text); return true; } catch (FormatException) { MessageBox.Show(textBox.Tag + " must be a decimal number.", Title); textBox.Focus(); return false; } } }
  • 46. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 46 The Class View window
  • 47. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 47 A class diagram that shows two of the classes* *Express Edition doesn’t have class diagrams or the Class Details window
  • 48. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 48 The syntax for creating a structure public struct StructureName { structure members... }
  • 49. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 49 A Product structure public struct Product { public string Code; public string Description; public decimal Price; public Product(string code, string description, decimal price) { this.Code = code; this.Description = description; this.Price = price; } public string GetDisplayText(string sep) { return Code + sep + Price.ToString("c") + sep + Description; } }
  • 50. Murach’s C# 2010, C12 © 2010, Mike Murach & Associates, Inc.Slide 50 Code that declares a variable as a structure type and assigns values to it Product p; // Create an instance of the Product structure p.Code = "CS10"; // Assign values to each instance variable p.Description = "Murach's C# 2010"; p.Price = 54.50m; string msg = p.GetDisplayText("n"); // Call a method Code that uses the structure’s constructor Product p = new Product("CS10", "Murach's C# 2010", 54.50m);