04 June 2007

YATIDK #2

Continuing the trend of yet another thing I didn't know (but probably should have):

I had always done:



Object o = ...

if (o.Type() == typeof(string))

{

   blah...

}



when i could have been doing:



Object o = ...

if ( o is string)

{

    blah...

}


Labels: ,

YATIDK #1

YATIDK = YetAnotherThingIDidn'tKnow
New segment for this blog where i talk about stuff i didn't know, but should have.

I already knew that if you have a multi-line string as so:




string s = @"Lorem ipsum dolor sit amet, consectetuer adipiscing
elit. Aliquam sit amet velit. Morbi sit amet sem. Pellentesque
suscipit, risus et laoreet convallis, tortor elit aliquet mi, quis aliquet magna
sem eget quam."
;




you place @ in order to read everything between " including CR

... anyway apparently if in that string you have "bob" in quotes the way you handle it is ""bob""
i.e.:



string s = @"Lorem ipsum dolor sit amet, consectetuer adipiscing
elit. Aliquam sit amet velit. Morbi sit amet sem. Pellentesque
"
"bob"" suscipit, risus et laoreet convallis, tortor elit aliquet mi, quis aliquet magna
sem eget quam."
;




its cleaner than changing to single quotes, concatenating multiple strings etc.
Now I Know...

Labels: ,