[AccessD] Moving to .Net (was Ded Moroz sends you ...)

Shamil Salakhetdinov shamil at smsconsulting.spb.ru
Tue Jan 4 15:20:07 CST 2011


Mike, Lambert, Dan, --

I didn't mean overloading first of all maybe more something as the following
class constructor syntax (available starting VS2008):

//Public Function SendEmail(
//Optional ByVal stgTo As String, _
//Optional ByVal stgSubject As String, _
//Optional ByVal stgMessage As String, _
//Optional ByVal blnBackup As Boolean, _
//Optional ByVal stgBackupFunction As String, _
//Optional ByVal stgAttachmentList As String, _
//Optional ByVal blnDisplay As Boolean, _
//Optional ByVal blnSendToCurrent As Boolean, _
//Optional ByVal blnHideEmailNotice As Boolean, _
//Optional varObjectType As Variant, _
//Optional ByVal stgObjectName As String, _
//Optional varOutputFormat As Variant, _
//Optional ByVal stgObjectFileName As String, _
//Optional ByVal blnExcludeOpenLink As Boolean) As Boolean

public class EMailer
{
    //Optional ByVal stgTo As String, _
    public string To { get; private set; }
    //Optional ByVal stgSubject As String, _
    public string Subject { get; private set; }
    //Optional ByVal stgMessage As String, _
    public string Message { get; private set; }
    //Optional ByVal blnBackup As Boolean, _
    public bool Backup { get; private set; }
    //Optional ByVal stgBackupFunction As String, _
    public string BackupFunction { get; private set; }
    //Optional ByVal stgAttachmentList As String, _
    public string AtachmentList { get; private set; }
    //Optional ByVal blnDisplay As Boolean, _
    public bool Display { get; private set; }
    //Optional ByVal blnSendToCurrent As Boolean, _
    public bool SendToCurrent { get; private set; }
    //Optional ByVal blnHideEmailNotice As Boolean, _
    public bool HideEMailNotice { get; private set; }
    //Optional varObjectType As Variant, _
    public object ObjectType { get; private set; }
    //Optional ByVal stgObjectName As String, _
    public string ObjectName { get; private set; }
    //Optional varOutputFormat As Variant, _
    public object OutputFormat { get; private set; }
    //Optional ByVal stgObjectFileName As String, _
    public string ObjectFileName { get; private set; }
    //Optional ByVal blnExcludeOpenLink As Boolean) As Boolean
    public bool ExcludeOpenLink { get; private set; }

    public void Send()
    {
        System.Console.WriteLine("To: {0}, Subject: '{1}', Message: {2}",
this.To, this.Subject, this.Message);  
    }

    public static void TestRun()
    {
        (new EMailer()
        {
             To = "test at gmail.com",
             Subject = "Test message",
             Message = "My test message..."
        }).Send();
    }
}

Thank you.

--
Shamil
 
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Heenan, Lambert
Sent: 4 ?????? 2011 ?. 21:28
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Moving to .Net (was Ded Moroz sends you ...)

Thanks Mike,

I realized that. Just wanted some clarification from Shamil on what he
meant. 

You can also overload operators in C#, just as you can in C++. So you can
define a '+' operator for a class to make it do concatenation or addition
that makes sense for the class.

BTW my first name is Lambert. :-)


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Michael Bahr
Sent: Tuesday, January 04, 2011 1:19 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Moving to .Net (was Ded Moroz sends you ...)

Heenan, what you are showing is called overloading.  Same method name but
different parameters and return type.  You typically see this with the
default constructor being overloaded, for example validating the input
values.  The default constructor mearly intializes the private variables to
a default value where an overloaded method actually checks if it is vaild
and throws exceptions if needed.  Overloading can also occur using inherited
methods (from the parent or superclass).

Mike

> When you say that optional parameters are not needed in C# is that 
> because you can just write a new method that has the same name but a 
> different signature?
>
> Long Foo() // this routine takes no parameters Long Foo(Long x) // 
> this routine takes one parameters
>
> ... Etc. etc.
>
> Lambert
>


--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list