-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
code updated implicit conversion from msdn
- Loading branch information
1 parent
66a211f
commit c8b1f70
Showing
4 changed files
with
56 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Ch11_P4_CustomConversions | ||
{ | ||
class Digit | ||
{ | ||
public double val; | ||
// ...other members | ||
|
||
public Digit(double d) // Consructor | ||
{ | ||
val = d; | ||
} | ||
|
||
public static implicit operator double(Digit d) | ||
{ | ||
return d.val; | ||
} | ||
|
||
public static implicit operator Digit(double d) | ||
{ | ||
return new Digit(d); | ||
} | ||
|
||
//// User-defined conversion from double to Digit | ||
//public static implicit operator Digit(double d) | ||
//{ | ||
// return new Digit(d); | ||
//} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Ch11-P4-CustomConversions/obj/Debug/Ch11-P4-CustomConversions.csproj.CoreCompileInputs.cache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1c6796e2a7b82ca27c61282efcb26c3fe40b1477 | ||
0095dc4b0b1b5e5266c992246e08d0ebe13895e5 |