string-concatenation

SQL Server String Concatenation with Null

主宰稳场 提交于 2019-11-26 07:26:59
问题 I am creating a computed column across fields of which some are potentially null. The problem is that if any of those fields is null, the entire computed column will be null. I understand from the Microsoft documentation that this is expected and can be turned off via the setting SET CONCAT_NULL_YIELDS_NULL. However, there I don\'t want to change this default behavior because I don\'t know its implications on other parts of SQL Server. Is there a way for me to just check if a column is null

Ternary operator and string concatenation quirk?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 06:44:16
问题 Hi I just want to know why this code yields (at least for me) an incorrect result. Well, probably i\'m in fault here $description = \'Paper: \' . ($paperType == \'bond\') ? \'Bond\' : \'Other\'; I was guessing that if paperType equals \'Bond\' then description is \'Paper: Bond\' and if paperType is not equals to \'Bond\' then description is \'Paper: Other\'. But when I run this code the results are description is either \'Bond\' or \'Other\' and left me wondering where the string \'Paper: \'

How do I concatenate strings and variables in PowerShell?

混江龙づ霸主 提交于 2019-11-26 06:11:09
问题 Suppose I have the following snippet: $assoc = New-Object psobject -Property @{ Id = 42 Name = \"Slim Shady\" Owner = \"Eminem\" } Write-host $assoc.Id + \" - \" + $assoc.Name + \" - \" + $assoc.Owner I\'d expect this snippet to show: 42 - Slim Shady - Eminem But instead it shows: 42 + - + Slim Shady + - + Eminem Which makes me think the + operator isn\'t appropriate for concatenating strings and variables. How should you approach this with PowerShell? 回答1: Write-Host "$($assoc.Id) - $($assoc

How to keep the spaces at the end and/or at the beginning of a String?

妖精的绣舞 提交于 2019-11-26 06:04:24
问题 I have to concatenate these two strings from my resource/value files: <string name=\"Toast_Memory_GameWon_part1\">you found ALL PAIRS ! on </string> <string name=\"Toast_Memory_GameWon_part2\"> flips !</string> I do it this way : String message_all_pairs_found = getString(R.string.Toast_Memory_GameWon_part1)+total_flips+getString(R.string.Toast_Memory_GameWon_part2); Toast.makeText(this, message_all_pairs_found, 1000).show(); But the spaces at the end of the first string and at the beginning

Ampersand vs plus for concatenating strings in VB.NET [duplicate]

醉酒当歌 提交于 2019-11-26 05:58:33
问题 This question already has answers here : String manipulation with & or + in VB.NET (6 answers) Closed 3 years ago . In VB.NET, is there any advantage to using & to concatenate strings instead of + ? For example Dim x as String = \"hello\" + \" there\" vs. Dim x as String = \"hello\" & \" there\" Yes, I know for a lot of string concatenations I\'d want to use StringBuilder , but this is more of a general question. 回答1: I've heard good, strong arguments in favor of both operators. Which

PHP string concatenation

浪尽此生 提交于 2019-11-26 04:45:57
I need to know if its possible to concatenate strings, as follows ? and if not, what is the alternative of doing so ? while ($personCount < 10) { $result+= $personCount . "person "; } echo $result; it should appear like 1 person 2 person 3 person etc.. You cann't use the + sign in concatenation so what is the alternative ? Just use . for concatenating. And you missed out the $personCount increment! while ($personCount < 10) { $result .= $personCount . ' people'; $personCount++; } echo $result; One step (IMHO) better $result .= $personCount . ' people'; while ($personCount < 10) { $result .= (

Why to use StringBuffer in Java instead of the string concatenation operator

时光怂恿深爱的人放手 提交于 2019-11-26 04:40:03
问题 Someone told me it\'s more efficient to use StringBuffer to concatenate strings in Java than to use the + operator for String s. What happens under the hood when you do that? What does StringBuffer do differently? 回答1: It's better to use StringBuilder (it's an unsynchronized version; when do you build strings in parallel?) these days, in almost every case, but here's what happens: When you use + with two strings, it compiles code like this: String third = first + second; To something like

How to concatenate strings in twig

[亡魂溺海] 提交于 2019-11-26 04:32:44
问题 Anyone knows how to concatenate strings in twig? I want to do something like: {{ concat(\'http://\', app.request.host) }} 回答1: This should work fine: {{ 'http://' ~ app.request.host }} To add a filter - like 'trans' - in the same tag use {{ ('http://' ~ app.request.host) | trans }} As Adam Elsodaney points out, you can also use string interpolation, this does require double quoted strings: {{ "http://#{app.request.host}" }} 回答2: Also a little known feature in Twig is string interpolation: {{

How to efficiently concatenate strings

吃可爱长大的小学妹 提交于 2019-11-26 04:28:48
问题 In Go, a string is a primitive type, which means it is read-only, and every manipulation of it will create a new string. So if I want to concatenate strings many times without knowing the length of the resulting string, what\'s the best way to do it? The naive way would be: s := \"\" for i := 0; i < 1000; i++ { s += getShortStringFromSomewhere() } return s but that does not seem very efficient. 回答1: Note added in 2018 From Go 1.10 there is a strings.Builder type, please take a look at this

String concatenation without &#39;+&#39; operator

可紊 提交于 2019-11-26 03:57:54
问题 I was playing with python and I realized we don\'t need to use \'+\' operator to concatenate strings unless it is used with values. For example: string1 = \'Hello\' \'World\' #1 works fine string2 = \'Hello\' + \'World\' #2 also works fine string3 = \'Hello\' string4 = \'World\' string5 = string3 string4 #3 causes syntax error string6 = string3 + string4 #4 works fine Now I have two questions: Why statement 3 does not work while statement 1 does? Is there any technical difference such as