Helping Developers Master PowerBuilder Classic and .NET

Yakov Werde

Subscribe to Yakov Werde: eMailAlertsEmail Alerts
Get Yakov Werde: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn

Blog Post

.NET Properties & Expressions

Watch out for this syntax issue

I was building a WPF POC app today in PB .NET 12.1 when I discovered this little anomaly:

System.Windows.Controls.ToolTip is a property not a string variable.  Here's the definition as seen on the Object Browser.

public virtual string ToolTip {public  get; public  set; }

/*  This compiles  */
string lstip
lstip = this.InnerControl.ToolTip //simple assignment statement to a string variable

mle_1.Text += sender.ToString( ) + ' ' + lstip + '~r~n'  //concatenate strings

/* However this does not compile */
mle_1.Text += sender.ToString( ) + ' ' + this.InnerControl.ToolTip + '~r~n'

/* Interesting... This does not compile either */
string lstip
lstip = this.InnerControl.ToolTip  + ' ' + this.InnerControl.ToolTip    //same error

The error message "Can't mix object and string"!!?

Looks like the getter is only called on a simple assignment statement not when used in an expression.

Apparently the PBCS.exe precompiler gets confused when a property is used in an expression - it can't understand that the getter returns a string.

Is your experience the same?

More Stories By Yakov Werde

Yakov Werde, a 25 year IT industry veteran, is a member of TeamSybase and the newly formed Sybase Customer Evangelist Team. Yakov is a recognized author, speaker and trainer who has been designing and delivering PowerBuilder, .NET, EaServer, Web App Development, and Java training for over 14 years to corporate, military and government developers. Prior to discovering his aptitude as an educator, Yakov worked as an architect, project manager and application coder in the trenches of application software development. Yakov holds a Masters in Education with a specialty in instructional design for online learning from Capella University and a BS in math and computer science from Florida International University. Yakov, managing partner of eLearnIT LLC (, authors and delivers workshops and web based eLearning tutorials to guide professional developers toward PowerBuilder Classic and .NET mastery. Follow Yakov on Twitter as @eLearnPB