string-concatenation

Why is there no exception when adding null to a string?

断了今生、忘了曾经 提交于 2020-01-14 07:19:10
问题 Why doesnt this throw an exception dont understand, obj is null object obj = null; Console.WriteLine("Hello World " + obj); 回答1: This compiles to Console.WriteLine(String.Concat("Hello World ", obj)); The String.Concat method ignores null parameters. It's defined like this: (From the .Net reference source) public static String Concat(Object arg0, Object arg1) { if (arg0==null) { arg0 = String.Empty; } if (arg1==null) { arg1 = String.Empty; } return Concat(arg0.ToString(), arg1.ToString()); }

Why is there no exception when adding null to a string?

為{幸葍}努か 提交于 2020-01-14 07:19:02
问题 Why doesnt this throw an exception dont understand, obj is null object obj = null; Console.WriteLine("Hello World " + obj); 回答1: This compiles to Console.WriteLine(String.Concat("Hello World ", obj)); The String.Concat method ignores null parameters. It's defined like this: (From the .Net reference source) public static String Concat(Object arg0, Object arg1) { if (arg0==null) { arg0 = String.Empty; } if (arg1==null) { arg1 = String.Empty; } return Concat(arg0.ToString(), arg1.ToString()); }

Concatenate rows in select query (in Advantage Data Architect)

安稳与你 提交于 2020-01-06 19:41:31
问题 How can I concatenate rows in select query? (in Advantage Data Architect) I tried run the following scripts: The first script: declare @str string; set @str = ''; select @str = @str + field_1 from my_table1 But I get a result where all rows contain "false", like this picture: Second script: declare @str string; select @str = coalesce(@str + ', ','') + field_1 from my_table1 This time, all rows are empty (note: the field from "my_table1" is not null). Picture: I tried to search the solution on

Concatenate rows in select query (in Advantage Data Architect)

不想你离开。 提交于 2020-01-06 19:39:45
问题 How can I concatenate rows in select query? (in Advantage Data Architect) I tried run the following scripts: The first script: declare @str string; set @str = ''; select @str = @str + field_1 from my_table1 But I get a result where all rows contain "false", like this picture: Second script: declare @str string; select @str = coalesce(@str + ', ','') + field_1 from my_table1 This time, all rows are empty (note: the field from "my_table1" is not null). Picture: I tried to search the solution on

Concatenate rows in select query (in Advantage Data Architect)

我怕爱的太早我们不能终老 提交于 2020-01-06 19:39:29
问题 How can I concatenate rows in select query? (in Advantage Data Architect) I tried run the following scripts: The first script: declare @str string; set @str = ''; select @str = @str + field_1 from my_table1 But I get a result where all rows contain "false", like this picture: Second script: declare @str string; select @str = coalesce(@str + ', ','') + field_1 from my_table1 This time, all rows are empty (note: the field from "my_table1" is not null). Picture: I tried to search the solution on

Concatenate a string for DisplayFor

拜拜、爱过 提交于 2020-01-06 07:00:31
问题 I have a model called Lines. On it I have a address class that contains a number of strings, i.e.: public string ReferenceKey { get; set; } public string Country { get; set; } public string County { get; set; } public string Postcode { get; set; } public string PremisesName { get; set; } public string PremisesName { get; set; } I get information back from a webservice call to an outside party and then populate these fields with the returned data - note in some cases they may not return

Bash string concatenation producing weird results [duplicate]

强颜欢笑 提交于 2020-01-06 04:36:08
问题 This question already has answers here : Concatenating strings in bash overwrites them (4 answers) Closed 2 years ago . My bash code file.sh : username=$1 pkgpath="/home/${username}_tmp.txt" echo $username echo $pkgpath Now running the script with the command bash file.sh abc should produce the result : abc /home/abc_tmp.txt But the output I'm getting is : abc _tmp.txtc Can someone explain why is this behavior occurring and how to obtain the desired result ? EDIT I'd like to mention that

SQL Server Concatenate Rows Using Many-To-Many Related Tables

微笑、不失礼 提交于 2020-01-04 14:39:26
问题 I've already searched for my problem, but most of the examples (if not all), have to deal with only one or two tables with a one-to-many relationship between them. So, here goes my scenario: My first table is: OrderID Quantity Price ---------------------------------- 18 1000.00 160.00 19 1000.00 40.00 22 1000.00 40.00 23 100.00 500.00 24 10.00 50.00 My second table is: ExtrasID Name ------------------- 1 Value 1 2 Value 2 3 Value 3 4 Value 4 5 Value 5 I have a many-to-many relationship

Python pandas groupby conditional concatenate strings into multiple columns

强颜欢笑 提交于 2020-01-04 11:02:38
问题 I am trying to group by a dataframe on one column, keeping several columns from one row in each group and concatenating strings from the other rows into multiple columns based on the value of one column. Here is an example... df = pd.DataFrame({'test' : ['a','a','a','a','a','a','b','b','b','b'], 'name' : ['aa','ab','ac','ad','ae','ba','bb','bc','bd','be'], 'amount' : [1, 2, 3, 4, 5, 6, 7, 8, 9, 9.5], 'role' : ['x','y','y','x','x','z','y','y','z','y']}) df amount name role test 0 1.0 aa x a 1

How to Concatenate String in Objective-C (iPhone)? [duplicate]

回眸只為那壹抹淺笑 提交于 2019-12-31 12:10:09
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: How do I concatenate strings in Objective-C? Firstly, the platform is iPhone and label.text changes the label displayed. Consider this scenario: I've an array of integers. And I want to display it on the screen. Here's my take on it: -(IBAction) updateText: (id)sender { int a[2]; a[0]=1; a[1]=2; a[2]=3; for (int i=0; i<=10;i++) label.text = [NSString stringByAppendingString: [NSString stringWithFormat: @"%i", a