Click here to Skip to main content
15,888,454 members
Home / Discussions / C#
   

C#

 
GeneralRe: Howto send Text to a Word Doc ? Pin
Anonymous17-Aug-03 20:06
Anonymous17-Aug-03 20:06 
GeneralOperator overloading with strings Pin
hzs11-Aug-03 20:15
hzs11-Aug-03 20:15 
GeneralRe: Operator overloading with strings Pin
J. Dunlap11-Aug-03 21:10
J. Dunlap11-Aug-03 21:10 
GeneralRe: Operator overloading with strings Pin
hzs12-Aug-03 1:39
hzs12-Aug-03 1:39 
GeneralRe: Operator overloading with strings Pin
Ista12-Aug-03 4:16
Ista12-Aug-03 4:16 
GeneralRe: Operator overloading with strings Pin
hzs12-Aug-03 20:09
hzs12-Aug-03 20:09 
GeneralRe: Operator overloading with strings Pin
Ista13-Aug-03 3:39
Ista13-Aug-03 3:39 
GeneralRe: Operator overloading with strings Pin
Julian Bucknall [MSFT]12-Aug-03 6:09
Julian Bucknall [MSFT]12-Aug-03 6:09 
Just want to point something out: Can you imagine the maintainance nightmare that would result from doing what you propose? If you read

string3 = string1 + string2;

in your code 6 or 12 months from now, would you know whether it meant "concatenate" or "treat the strings as numbers and add"? Would your replacement?

What I'm saying is that although the language might allow you to do what you want, do you really want to do it? It's great writing software that's only used once, to prove a point, as it were, but the reality of our game is that we generally have to write code that we'll have to maintain down the road (and if not us, then someone else). In that case, the simpler you express the intent of your program in code, the simpler it is to test and maintain, and the easier it is to go home at 5 o'clock.

My recommendation is to create a small class that encapsulates what you want to do. Override the + operator (and the += operator, and the - operator and the -= operator) to your heart's content at that point. It won't be as confusing as "sometimes in my code the + operator on strings means this, other times it means that".

Cheers, Julian
Program Manager, C#

This posting is provided "AS IS" with no warranties, and confers no rights.
GeneralRe: Operator overloading with strings Pin
hzs12-Aug-03 20:25
hzs12-Aug-03 20:25 
GeneralRe: Operator overloading with strings Pin
isarfraz17-Aug-03 19:53
isarfraz17-Aug-03 19:53 
GeneralRe: Operator overloading with strings Pin
Heath Stewart12-Aug-03 7:06
protectorHeath Stewart12-Aug-03 7:06 
GeneralRe: Operator overloading with strings Pin
Rein Hillmann12-Aug-03 8:17
Rein Hillmann12-Aug-03 8:17 
GeneralRe: Operator overloading with strings Pin
hzs12-Aug-03 20:32
hzs12-Aug-03 20:32 
GeneralOMG I'm getting VB Script flashbacks! Pin
Furty12-Aug-03 22:32
Furty12-Aug-03 22:32 
GeneralRe: Operator overloading with strings Pin
Ista13-Aug-03 3:43
Ista13-Aug-03 3:43 
QuestionGet/Set file and dir permissions...??? Pin
vlusardi11-Aug-03 18:24
vlusardi11-Aug-03 18:24 
GeneralMath Pin
eggie511-Aug-03 16:40
eggie511-Aug-03 16:40 
GeneralRe: Math Pin
apferreira11-Aug-03 17:13
apferreira11-Aug-03 17:13 
GeneralRe: Math Pin
eggie511-Aug-03 18:11
eggie511-Aug-03 18:11 
GeneralRe: Math Pin
eggie511-Aug-03 18:25
eggie511-Aug-03 18:25 
GeneralRe: Math Pin
Philip Fitzsimons12-Aug-03 3:19
Philip Fitzsimons12-Aug-03 3:19 
GeneralForm Selection application Pin
azusakt11-Aug-03 15:30
azusakt11-Aug-03 15:30 
GeneralRe: Form Selection application Pin
Ista13-Aug-03 13:31
Ista13-Aug-03 13:31 
QuestionHow to get bimap of a form Pin
sumeat11-Aug-03 14:02
sumeat11-Aug-03 14:02 
AnswerRe: How to get bimap of a form Pin
jtmtv1811-Aug-03 14:21
jtmtv1811-Aug-03 14:21 

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.