Skip to content

Commit 79866dd

Browse files
authored
Merge pull request #49068 from wwlpublish/ecfa51792a2f87fff2572ebb6d3d78a1819cc8d43a7045021382e22e04d44380-live
Modules/M02-implement-class-properties-methods
2 parents d484324 + cd79a15 commit 79866dd

21 files changed

+1771
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.implement-class-properties-methods.introduction
3+
title: Introduction
4+
metadata:
5+
title: Introduction
6+
description: "Introduction"
7+
ms.date: 02/10/2025
8+
author: wwlpublish
9+
ms.author: cahowd
10+
ms.topic: unit
11+
durationInMinutes: 2
12+
content: |
13+
[!include[](includes/1-introduction.md)]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.implement-class-properties-methods.summary
3+
title: Summary
4+
metadata:
5+
title: Summary
6+
description: "Summary"
7+
ms.date: 02/10/2025
8+
author: wwlpublish
9+
ms.author: cahowd
10+
ms.topic: unit
11+
durationInMinutes: 2
12+
content: |
13+
[!include[](includes/10-summary.md)]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.implement-class-properties-methods.examine-class-members
3+
title: Examine class members
4+
metadata:
5+
title: Examine class members
6+
description: "Examine class members"
7+
ms.date: 02/10/2025
8+
author: wwlpublish
9+
ms.author: cahowd
10+
ms.topic: unit
11+
durationInMinutes: 6
12+
content: |
13+
[!include[](includes/2-examine-class-members.md)]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.implement-class-properties-methods.create-class-properties
3+
title: Get started with class properties and accessors
4+
metadata:
5+
title: Get started with class properties and accessors
6+
description: "Get started with class properties and accessors"
7+
ms.date: 02/10/2025
8+
author: wwlpublish
9+
ms.author: cahowd
10+
ms.topic: unit
11+
durationInMinutes: 11
12+
content: |
13+
[!include[](includes/3-create-class-properties.md)]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.implement-class-properties-methods.examine-automatically-implemented-properties
3+
title: Examine automatically implemented properties
4+
metadata:
5+
title: Examine automatically implemented properties
6+
description: "Examine automatically implemented properties"
7+
ms.date: 02/10/2025
8+
author: wwlpublish
9+
ms.author: cahowd
10+
ms.topic: unit
11+
durationInMinutes: 12
12+
content: |
13+
[!include[](includes/4-examine-automatically-implemented-properties.md)]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.implement-class-properties-methods.restrict-access-properties
3+
title: Restrict access to properties
4+
metadata:
5+
title: Restrict access to properties
6+
description: "Restrict access to properties"
7+
ms.date: 02/10/2025
8+
author: wwlpublish
9+
ms.author: cahowd
10+
ms.topic: unit
11+
durationInMinutes: 11
12+
content: |
13+
[!include[](includes/5-restrict-access-properties.md)]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.implement-class-properties-methods.create-class-methods
3+
title: Implement class methods and parameters
4+
metadata:
5+
title: Implement class methods and parameters
6+
description: "Implement class methods and parameters"
7+
ms.date: 02/10/2025
8+
author: wwlpublish
9+
ms.author: cahowd
10+
ms.topic: unit
11+
durationInMinutes: 14
12+
content: |
13+
[!include[](includes/6-create-class-methods.md)]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.implement-class-properties-methods.examine-extension-methods
3+
title: Implement extension methods for a class
4+
metadata:
5+
title: Implement extension methods for a class
6+
description: "Implement extension methods for a class"
7+
ms.date: 02/10/2025
8+
author: wwlpublish
9+
ms.author: cahowd
10+
ms.topic: unit
11+
durationInMinutes: 7
12+
content: |
13+
[!include[](includes/7-examine-extension-methods.md)]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.implement-class-properties-methods.exercise-create-properties-methods
3+
title: Exercise - Update a class with properties and methods in C#
4+
metadata:
5+
title: Exercise - Update a class with properties and methods in C#
6+
description: "Exercise - Update a class with properties and methods in C#"
7+
ms.date: 02/10/2025
8+
author: wwlpublish
9+
ms.author: cahowd
10+
ms.topic: unit
11+
durationInMinutes: 35
12+
content: |
13+
[!include[](includes/8-exercise-create-properties-methods.md)]
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.implement-class-properties-methods.knowledge-check
3+
title: Knowledge check
4+
metadata:
5+
title: Knowledge check
6+
description: "Knowledge check"
7+
ms.date: 02/10/2025
8+
author: wwlpublish
9+
ms.author: cahowd
10+
ms.topic: unit
11+
durationInMinutes: 6
12+
quiz:
13+
title: "Check your knowledge"
14+
questions:
15+
- content: "What is a property?"
16+
choices:
17+
- content: "A property refers to the connectivity between two objects."
18+
isCorrect: false
19+
explanation: "Incorrect. A property does not refer to the connectivity between two objects."
20+
- content: "It's a piece of land or real estate."
21+
isCorrect: false
22+
explanation: "Incorrect. While the noun property can be defined this way, it isn't how the term is used in computer programming."
23+
- content: "A property is a class member that provides a mechanism to read, write, or compute the values of a field."
24+
isCorrect: true
25+
explanation: "Correct. A property allows for the getting, setting, and computing the values of a field."
26+
- content: "How are return values returned from a method?"
27+
choices:
28+
- content: "With a goto statement."
29+
isCorrect: false
30+
explanation: "Incorrect. A goto statement doesn't exist in C#."
31+
- content: "With a using statement."
32+
isCorrect: false
33+
explanation: "Incorrect. Using statements aren't used for returning a value from a method."
34+
- content: "With a return statement."
35+
isCorrect: true
36+
explanation: "Correct. You use a return statement to return a value from a method."
37+
- content: "What is the purpose of the 'get' accessor in a class property?"
38+
choices:
39+
- content: "It assigns a value to the property."
40+
isCorrect: false
41+
explanation: "Incorrect. The 'get' accessor does not assign a value to the property, it retrieves the value of the property."
42+
- content: "It validates data before allowing a change."
43+
isCorrect: false
44+
explanation: "Incorrect. While properties can be used to validate data, this isn't the specific role of the 'get' accessor. The 'get' accessor is used to retrieve the value of the property."
45+
- content: "It retrieves the value of the property."
46+
isCorrect: true
47+
explanation: "Correct. The 'get' accessor is used to retrieve the value of the property."
48+
- content: "What is the purpose of automatically implemented properties in C#?"
49+
choices:
50+
- content: "They allow direct access to private fields of a class."
51+
isCorrect: false
52+
explanation: "Incorrect. Automatically implemented properties do not allow direct access to private fields. They create a private, anonymous backing field that can only be accessed through the property's `get` and `set` accessors."
53+
- content: "They make property-declaration more concise when no other logic is required in the property accessors."
54+
isCorrect: true
55+
explanation: "Correct. Automatically implemented properties simplify the declaration of properties when no other logic is needed in the `get` and `set` accessors."
56+
- content: "They enable the creation of mutable classes only."
57+
isCorrect: false
58+
explanation: "Incorrect. Automatically implemented properties can be used in both mutable and immutable classes. The mutability depends on how the accessors are defined."
59+
- content: "What is the purpose of using access modifiers in a class?"
60+
choices:
61+
- content: "To specify how accessible each of its members is to code outside of the class and limit the potential for coding errors or malicious exploits."
62+
isCorrect: true
63+
explanation: "Correct. Access modifiers are used to specify the accessibility of class members and to limit the potential for coding errors or malicious exploits."
64+
- content: "To make all methods and properties accessible only by code in the same class or a derived class."
65+
isCorrect: false
66+
explanation: "Incorrect. Not all methods and properties are meant to be accessed only by code in the same class or a derived class. Some are meant to be accessed from outside the class."
67+
- content: "To allow all methods and variables to be accessed from outside of the class or assembly."
68+
isCorrect: false
69+
explanation: "Incorrect. Access modifiers are used to limit the accessibility of methods and variables, not to allow all of them to be accessed from outside."
70+
- content: "What is the priority of extension methods compared to instance methods during compile time?"
71+
choices:
72+
- content: "Instance methods have higher priority than extension methods."
73+
isCorrect: true
74+
explanation: "Correct. If a type has an instance method and an extension method with the same signature, the compiler will bind to the instance method."
75+
- content: "Extension methods and instance methods have equal priority."
76+
isCorrect: false
77+
explanation: "Incorrect. Instance methods are prioritized over extension methods during compile time."
78+
- content: "Extension methods have higher priority than instance methods."
79+
isCorrect: false
80+
explanation: "Incorrect. During compile time, instance methods always have higher priority than extension methods."

0 commit comments

Comments
 (0)