Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
String literal in multiple lines in C#
Message
From
22/04/2007 18:23:07
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
22/04/2007 06:17:12
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 2.0
Miscellaneous
Thread ID:
01218662
Message ID:
01218707
Views:
18
>>>>Use @ prefix.
>>>
>>>@ prefix adds line feeds to strings.
>>>So result string is different and cannot be used in case label.
>>>
>>>>PS: In most cases it's easier to use StringBuilder.
>>>
>>>I need to use string literal in case label as shown in example.
>>>case label cannot be expression so using StringBuilder is not possible.
>>
>>
>>strin s1 = @"IR(""xxx"")+
>>sql('sele tasudok from dok x
>> where doktyyp+str(dokumnr,7)= ""G""+
>>str(dok.krdokumnr,7) ','')".Replace("\r\n",String.Empty);
>>
>>//..
>>case s1:
>>
>>
>>
>>Using such a string as a label is dangerous but it is up to you.
>>Cetin
>
>Thank you. I also found that
>
>case @"ssss""bbbb"+
> @"dfdgfg""dfgf""":
>
>works. This does not reqire separate statements for case label creation so this is better, is'nt it?

No. IMHO it is calling for trouble to use a string longer than a word in a switch statement.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform