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?

Mixed Reality Toolkit V2開発環境構築(2020/01版)
Mixed Reality Toolkit V2開発環境構築(2020/01版)Mixed Reality Toolkit V2開発環境構築(2020/01版)
Mixed Reality Toolkit V2開発環境構築(2020/01版)Takahiro Miyaura
 
HTML & CSS: Chapter 03
HTML & CSS: Chapter 03HTML & CSS: Chapter 03
HTML & CSS: Chapter 03Steve Guinan
 
Unityネイティブプラグインマニアクス #denatechcon
Unityネイティブプラグインマニアクス #denatechconUnityネイティブプラグインマニアクス #denatechcon
Unityネイティブプラグインマニアクス #denatechconDeNA
 
UnityのフリーライセンスでPC-Android通信を実装するまで
UnityのフリーライセンスでPC-Android通信を実装するまでUnityのフリーライセンスでPC-Android通信を実装するまで
UnityのフリーライセンスでPC-Android通信を実装するまでHiroto Makiyama
 
Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)
Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)
Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)Nuzhat Memon
 
【Unite 2018 Tokyo】60fpsのその先へ!スマホの物量限界に挑んだSTG「アカとブルー」の開発設計
【Unite 2018 Tokyo】60fpsのその先へ!スマホの物量限界に挑んだSTG「アカとブルー」の開発設計【Unite 2018 Tokyo】60fpsのその先へ!スマホの物量限界に挑んだSTG「アカとブルー」の開発設計
【Unite 2018 Tokyo】60fpsのその先へ!スマホの物量限界に挑んだSTG「アカとブルー」の開発設計UnityTechnologiesJapan002
 
Chapter 5 Designing for the mobile web
Chapter 5 Designing for the mobile webChapter 5 Designing for the mobile web
Chapter 5 Designing for the mobile webDr. Ahmed Al Zaidy
 
Unityで PhotonCloudを使ってリアルタイム・マルチプレイヤーゲームを作っちゃおう【導入編】
Unityで PhotonCloudを使ってリアルタイム・マルチプレイヤーゲームを作っちゃおう【導入編】Unityで PhotonCloudを使ってリアルタイム・マルチプレイヤーゲームを作っちゃおう【導入編】
Unityで PhotonCloudを使ってリアルタイム・マルチプレイヤーゲームを作っちゃおう【導入編】GMO GlobalSign Holdings K.K.
 
ライター・イン・レジデンスとはなにか
ライター・イン・レジデンスとはなにかライター・イン・レジデンスとはなにか
ライター・イン・レジデンスとはなにかTell-Kaz Dambala
 
iPhoneでリアルタイムマルチプレイを実現!Photon Network Engine
iPhoneでリアルタイムマルチプレイを実現!Photon Network EngineiPhoneでリアルタイムマルチプレイを実現!Photon Network Engine
iPhoneでリアルタイムマルチプレイを実現!Photon Network EngineGMO GlobalSign Holdings K.K.
 
Deep Dive async/await in Unity with UniTask(UniRx.Async)
Deep Dive async/await in Unity with UniTask(UniRx.Async)Deep Dive async/await in Unity with UniTask(UniRx.Async)
Deep Dive async/await in Unity with UniTask(UniRx.Async)Yoshifumi Kawai
 
リアルタイムなゲームの開発でコンテナを使ってみたら簡単便利で激安だったのでオススメしたい
リアルタイムなゲームの開発でコンテナを使ってみたら簡単便利で激安だったのでオススメしたいリアルタイムなゲームの開発でコンテナを使ってみたら簡単便利で激安だったのでオススメしたい
リアルタイムなゲームの開発でコンテナを使ってみたら簡単便利で激安だったのでオススメしたいYutoNishine
 
CSS3 Media Queries
CSS3 Media QueriesCSS3 Media Queries
CSS3 Media QueriesRuss Weakley
 
Introduction to threejs
Introduction to threejsIntroduction to threejs
Introduction to threejsGareth Marland
 
Introduction to three.js
Introduction to three.jsIntroduction to three.js
Introduction to three.jsyuxiang21
 

Was ist angesagt? (20)

Mixed Reality Toolkit V2開発環境構築(2020/01版)
Mixed Reality Toolkit V2開発環境構築(2020/01版)Mixed Reality Toolkit V2開発環境構築(2020/01版)
Mixed Reality Toolkit V2開発環境構築(2020/01版)
 
【Unity】Scriptable object 入門と活用例
【Unity】Scriptable object 入門と活用例【Unity】Scriptable object 入門と活用例
【Unity】Scriptable object 入門と活用例
 
HTML & CSS: Chapter 03
HTML & CSS: Chapter 03HTML & CSS: Chapter 03
HTML & CSS: Chapter 03
 
Exception handling
Exception handlingException handling
Exception handling
 
Unityネイティブプラグインマニアクス #denatechcon
Unityネイティブプラグインマニアクス #denatechconUnityネイティブプラグインマニアクス #denatechcon
Unityネイティブプラグインマニアクス #denatechcon
 
UnityのフリーライセンスでPC-Android通信を実装するまで
UnityのフリーライセンスでPC-Android通信を実装するまでUnityのフリーライセンスでPC-Android通信を実装するまで
UnityのフリーライセンスでPC-Android通信を実装するまで
 
Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)
Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)
Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)
 
【Unite 2018 Tokyo】60fpsのその先へ!スマホの物量限界に挑んだSTG「アカとブルー」の開発設計
【Unite 2018 Tokyo】60fpsのその先へ!スマホの物量限界に挑んだSTG「アカとブルー」の開発設計【Unite 2018 Tokyo】60fpsのその先へ!スマホの物量限界に挑んだSTG「アカとブルー」の開発設計
【Unite 2018 Tokyo】60fpsのその先へ!スマホの物量限界に挑んだSTG「アカとブルー」の開発設計
 
Intro to Three.js
Intro to Three.jsIntro to Three.js
Intro to Three.js
 
Operators in java
Operators in javaOperators in java
Operators in java
 
Chapter 5 Designing for the mobile web
Chapter 5 Designing for the mobile webChapter 5 Designing for the mobile web
Chapter 5 Designing for the mobile web
 
Unityで PhotonCloudを使ってリアルタイム・マルチプレイヤーゲームを作っちゃおう【導入編】
Unityで PhotonCloudを使ってリアルタイム・マルチプレイヤーゲームを作っちゃおう【導入編】Unityで PhotonCloudを使ってリアルタイム・マルチプレイヤーゲームを作っちゃおう【導入編】
Unityで PhotonCloudを使ってリアルタイム・マルチプレイヤーゲームを作っちゃおう【導入編】
 
ライター・イン・レジデンスとはなにか
ライター・イン・レジデンスとはなにかライター・イン・レジデンスとはなにか
ライター・イン・レジデンスとはなにか
 
iPhoneでリアルタイムマルチプレイを実現!Photon Network Engine
iPhoneでリアルタイムマルチプレイを実現!Photon Network EngineiPhoneでリアルタイムマルチプレイを実現!Photon Network Engine
iPhoneでリアルタイムマルチプレイを実現!Photon Network Engine
 
Deep Dive async/await in Unity with UniTask(UniRx.Async)
Deep Dive async/await in Unity with UniTask(UniRx.Async)Deep Dive async/await in Unity with UniTask(UniRx.Async)
Deep Dive async/await in Unity with UniTask(UniRx.Async)
 
Riderはいいぞ!
Riderはいいぞ!Riderはいいぞ!
Riderはいいぞ!
 
リアルタイムなゲームの開発でコンテナを使ってみたら簡単便利で激安だったのでオススメしたい
リアルタイムなゲームの開発でコンテナを使ってみたら簡単便利で激安だったのでオススメしたいリアルタイムなゲームの開発でコンテナを使ってみたら簡単便利で激安だったのでオススメしたい
リアルタイムなゲームの開発でコンテナを使ってみたら簡単便利で激安だったのでオススメしたい
 
CSS3 Media Queries
CSS3 Media QueriesCSS3 Media Queries
CSS3 Media Queries
 
Introduction to threejs
Introduction to threejsIntroduction to threejs
Introduction to threejs
 
Introduction to three.js
Introduction to three.jsIntroduction to three.js
Introduction to three.js
 

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

Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 

Kürzlich hochgeladen (20)

Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 

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);