Click here to Skip to main content
15,899,632 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: DialogBasics as in MFC. Pin
Bram van Kampen17-May-13 9:35
Bram van Kampen17-May-13 9:35 
GeneralRe: DialogBasics as in MFC. Pin
Richard MacCutchan17-May-13 22:45
mveRichard MacCutchan17-May-13 22:45 
QuestionI suspect there's a Pattern for This: Optional Parameters vs. Overloading Pin
M-Badger15-May-13 11:43
M-Badger15-May-13 11:43 
AnswerRe: I suspect there's a Pattern for This: Optional Parameters vs. Overloading Pin
Eddy Vluggen16-May-13 5:01
professionalEddy Vluggen16-May-13 5:01 
GeneralRe: I suspect there's a Pattern for This: Optional Parameters vs. Overloading Pin
M-Badger16-May-13 8:34
M-Badger16-May-13 8:34 
GeneralRe: I suspect there's a Pattern for This: Optional Parameters vs. Overloading Pin
Eddy Vluggen16-May-13 9:13
professionalEddy Vluggen16-May-13 9:13 
GeneralRe: I suspect there's a Pattern for This: Optional Parameters vs. Overloading Pin
M-Badger16-May-13 9:57
M-Badger16-May-13 9:57 
GeneralRe: I suspect there's a Pattern for This: Optional Parameters vs. Overloading Pin
Eddy Vluggen16-May-13 11:25
professionalEddy Vluggen16-May-13 11:25 
Mike-MadBadger wrote:
I now have an instance of an object that I can start using to change the thing object without directly referring to thing, feels like a recipe for confusion...

The effect would also be there without the new object; any object that's embedded in a property can be put in a variable, and one can manipulate the referenced object without looking at whose property it was.
VB
Public Class Class1

    Private _param As Double
    Private _methods As ToGreyMethods

    Public Sub New(ByVal amount As Double)
        Me._param = amount
        Me._methods = New ToGreyMethods(Me)
    End Sub

    Public Property Param() As Double
        Get
            Return Me._param
        End Get
        Set(ByVal value As Double)
            If Not value = Me._param Then
                Me._param = value
            End If
        End Set
    End Property

    Public ReadOnly Property ToGrey() As ToGreyMethods
        Get
            Return _methods
        End Get
    End Property

    Public Class ToGreyMethods

        Private _outer As Class1

        Public Sub New(ByRef outer As Class1)
            Me._outer = outer
        End Sub

        Public Sub Increase(ByVal amount As Double)
            Me._outer.Param += amount
        End Sub

        Public Sub Decrease(ByVal amount As Double)
            Me._outer.Param -= amount
        End Sub
    End Class

End Class

Module Module1

    Sub Main()
        Dim thing As Class1 = New Class1(10)
        thing.ToGrey.Increase(5)
        Console.WriteLine(thing.Param.ToString())
        thing.ToGrey.Decrease(10)
        Console.WriteLine(thing.Param.ToString())

        ' Dim whoops2 As Font = Form1.Font <- now you got the same thing :)
        Dim whoops As Class1.ToGreyMethods = thing.ToGrey()

        Console.ReadKey()
    End Sub

End Module

Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]

GeneralRe: I suspect there's a Pattern for This: Optional Parameters vs. Overloading Pin
M-Badger16-May-13 9:58
M-Badger16-May-13 9:58 
GeneralRe: I suspect there's a Pattern for This: Optional Parameters vs. Overloading Pin
Eddy Vluggen16-May-13 11:26
professionalEddy Vluggen16-May-13 11:26 
AnswerRe: I suspect there's a Pattern for This: Optional Parameters vs. Overloading Pin
jschell16-May-13 7:57
jschell16-May-13 7:57 
GeneralRe: I suspect there's a Pattern for This: Optional Parameters vs. Overloading Pin
M-Badger16-May-13 8:37
M-Badger16-May-13 8:37 
GeneralRe: I suspect there's a Pattern for This: Optional Parameters vs. Overloading Pin
jschell17-May-13 10:13
jschell17-May-13 10:13 
AnswerRe: I suspect there's a Pattern for This: Optional Parameters vs. Overloading Pin
TnTinMn16-May-13 13:37
TnTinMn16-May-13 13:37 
GeneralRe: I suspect there's a Pattern for This: Optional Parameters vs. Overloading Pin
M-Badger17-May-13 6:49
M-Badger17-May-13 6:49 
GeneralRe: I suspect there's a Pattern for This: Optional Parameters vs. Overloading Pin
TnTinMn17-May-13 8:33
TnTinMn17-May-13 8:33 
GeneralRe: I suspect there's a Pattern for This: Optional Parameters vs. Overloading Pin
M-Badger17-May-13 21:47
M-Badger17-May-13 21:47 
QuestionAssembly Loading Pin
#realJSOP14-May-13 5:10
professional#realJSOP14-May-13 5:10 
AnswerRe: Assembly Loading Pin
Jasmine250114-May-13 6:18
Jasmine250114-May-13 6:18 
GeneralRe: Assembly Loading Pin
#realJSOP14-May-13 6:57
professional#realJSOP14-May-13 6:57 
GeneralRe: Assembly Loading Pin
Jasmine250114-May-13 7:12
Jasmine250114-May-13 7:12 
AnswerRe: Assembly Loading Pin
jschell14-May-13 9:22
jschell14-May-13 9:22 
GeneralRe: Assembly Loading Pin
Jasmine250114-May-13 11:36
Jasmine250114-May-13 11:36 
GeneralRe: Assembly Loading Pin
jschell15-May-13 8:23
jschell15-May-13 8:23 
AnswerRe: Assembly Loading Pin
Abhinav S15-May-13 8:16
Abhinav S15-May-13 8:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.